mercredi 29 novembre 2017

Store different multiple Object values when using same Object multiple time

Have created multiple classes, which are being called from the code at different times. The requirement is to store the values/data for each call, as it is later used for verification purposes.

Class/Object being called:

public class NameGenderDoB extends Base {

    private static Logger logger = Logger.getLogger(NameGenderDoB.class);
    DataGen dataGen = new DataGen();

    FamilyAndGivenNames familyGivenName = new FamilyAndGivenNames();

    private String gender = "Female";
    private String dateOfBirth = DataGen.getBirthday(22);

    public String getgender() {
        return gender;
    }

    public void setgender(String gender) {
        this.gender = gender;
    }

    public String getDateOfBirth() {
        return dateOfBirth;
    }

    public void setDateOfBirth(String dateOfBirth) {
        this.dateOfBirth = dateOfBirth;
    }

    public void Gender(){
        System.err.format("@ Fill Page: %s\n", "In Gender");
        choose(gender);
    }

    public void DoB(){
        fill_in("Date of birth", dateOfBirth);
    }

    public void NameGenderAndDoB() {
        FamilyGivenName.Family_And_Given_Names();
        Gender();
        DoB();
    }
}

Caller Code:

public class Application extends Base {

    public Application(){}

    private static Logger logger = Logger.getLogger(Application.class);
    DataGen dataGen = new DataGen();

    FamilyAndGivenNames familyGivenName;
    NamesSexAndDoB nameSexDoB;

    public void fill_Page(){
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        assertThat(shouldSeeTextInPage("Application"), equalTo(true));
        System.err.format("@ Fill Page: %s\n", methodName);
        familyGivenName.Family_And_Given_Names();
        nameSexDoB.Gender();
        nameSexDoB.DoB();
        familyGivenName.Family_And_Given_Names();
    }

    public void fill_Page(String formNumber){
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        if (formNumber == "10") {
            assertThat(shouldSeeTextInPage("Application Done"), equalTo(true));
            System.err.format("@ Fill Page: %s\n", methodName);
            familyGivenName.Family_And_Given_Names();
            nameSexDoB.Gender();
            nameSexDoB.DoB();
            familyGivenName.Family_And_Given_Names();
        }
    }
}

So in the above, I am calling the methods for DoB(), FamilyAndGivenNames() and Gender() from my code multiple times.

But I wish to store the data for each call, so that I can use it later in another method to verify that the data was entered correctly or not.

Is there some way I can do this, as a call to the method will overwrite the previous called data?

Aucun commentaire:

Enregistrer un commentaire