jeudi 23 juin 2016

Skipping inner methods in Mockito

I am trying to test the below method using mockito. I wanted to skip getProfileItemFinder().retrieveEmailRecipient(email) method call when executing class.getUserWishList("abc@gmail.com");

I have tried the below code, but whenever I am trying to run the code I am getting mockito exception at doReturn. Can you please suggest what I am doing wrong.

Sample Mock Method:

profileItemFinder = spy(new TestProfileItemFinder());
doReturn(profileItem).when( profileItemFinder.retrieveEmailRecipient(email));

Original Method:

public List<Map<String, Object>> getUserWishList(String email) {
    // JSONArray profileGiftList = new JSONArray();
    ---------------------------------------------
    -----------------------------------------------
    if (email != null) {

        RepositoryItem profileItem = getProfileItemFinder().retrieveEmailRecipient(email);

        if (profileItem != null) {
      ----------------------------------
      --------------------------------

    }

            }
        }
    }

    ---------------------------

}

Aucun commentaire:

Enregistrer un commentaire