I am making a junit test for a module.
when(myDetailsFacade.getMyDetailsInfo(anyLong())).thenReturn(null);
mrc.getFlowScoe().put("action", "create");
try{
instance.initialiseForm(mrc, mpr);
}catch (Exception e){
fail("Shouldn't get here");
}
model=(MyDetailsForm)mrc.getFlowScope().get("myDetailsFormModel");
assertNotNull(model);
assertEquals(model.getNationality(), "USA");
and i am getting this error
org.mockito.excetions.misusing.MissingMethodInvocationException:
when()requires an argument which has to be a method call on a mock.
For example
when(mock.getArticles()).thenReturn(articles);
in out facade we are getting hardcode value, like.
private myDetails getMyDetailsData{
myDetails.setNationality("USA");
return myDetails;
}
this is my initialiseform method which i am trying to test.
public void initialiseForm (RequestContext requestContext, PortletRequest portletRequest){
requestContext.getFlowScope().put("getTitles", getTitles);
requestContext.getFlowScope().put("getGender", getGender);
BasicModel model = (BasicModel)requestContext.getFlowScope().get("BasicModel");
if(model == null){
model = new BasicModel();
}
model.setEmpName("Edward");
}
And here is the getTitles method in same java file.
private Map <String, String> getTitles(){
option.put("Dr", "Dr");
option.put("Mr", "Mr");
return option;
}