lundi 6 février 2017

How to write test cases for the following method that holds the local object return by the database?

Currently, I am using TestNG and try to write the test case for the manipulateMetaData() method. Inside that method, metaData is given by the repository. And then the metaData is updated according to the given list of contact.

I stuck while writing the test case for manipulateMetaData() method.

public class MetaData{
    String email;
    Map<String, Integer> count = new HashMap<>();

    public void setEmail(String email){
        this.email = email;
    }

    public void updateCount(List<String> contact){
        // perform the calculation and update the count.
    }
}

public MetaData manipulateMetaData(String emailAddress, List<String> contact){

    MetaData metaData = metaDataRepository.findOneByEmail(emailAddress);

    if(metaData == null){
        metaData = new MetaData();
        metaData.setEmail(emailAddress);
    }

    metaData.updateCount(List<String> contact);

    return metaData;
}

Aucun commentaire:

Enregistrer un commentaire