I'm using InjectMocks for DAo class and setting dependency using @Mock. The @Before and @After annotations used for setup method and called MockitoAnnotations.initMocks(this);. Here is my mockito code
@Test
public void testIsMemberExists_DateOffsetFlag_False_Success() {
//Set Up
BaseRequest request = new BaseRequest();
request.setMemberId(11111111L);
//Expectation
when(wellnessProgramsDAO.isMemberExists(request)).thenReturn(true);
//SUT
boolean response = wellnessProgramsDAO.isMemberExists(request);
//Verify
Assert.assertEquals(response, true);
}
Here is method from DAO
@Override
public boolean isMemberExists(BaseRequest request) {
LOGGER.debug("Calling DOA impl to get isMemberExists");
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("memberId", request.getMemberId());
if(dateUtil.isDateOffsetFlag()) {
Date date = referenceDataDAO.getClaimProcessDate();
params.put(CURRENT_DATE, dateUtil.getCurrentSystemDateInDBFormat(date));
} else {
params.put(CURRENT_DATE, dateUtil.getCurrentSystemDateInDBFormat());
}
boolean isMemberVIP = getSqlSession().selectOne("wellnessPrograms.isMemberExists", params);
LOGGER.debug("isMemberExists from DB "+isMemberVIP);
return isMemberVIP;
}
I'm getting null pointer exception while executing selectone. I have debugged code and session is available, not sure why I'm getting null pointer. Appreciate any help.
Aucun commentaire:
Enregistrer un commentaire