After resolve mi first mockito issue, i found my second one(very similar to my first one, but i don't know how to fix it)
I have this rest java function:
@GET
@Path("/deleteEmployee")
@Produces("application/json")
public ReturnCode deleteEmployee(@QueryParam("empId") String empIdToDelete)
{
ReturnCode returnCode = new ReturnCode(Constants.NO_ERROR_CODE, Constants.NO_ERROR_TEXT);
SessionFactory sessionFactory = (SessionFactory) context.getAttribute("SessionFactory");
and this test:
@Test
public void testDeleteServlet() throws Exception {
ServletContext context = mock (ServletContext.class, RETURNS_DEEP_STUBS);
SessionFactory factory = contextInitialized();
when(context.getAttribute("SessionFactory")).thenReturn(factory);
new EmployeeOps().deleteEmployee("33");
}
Why always crashes with null pointer in SessionFactory sessionFactory = (SessionFactory) context.getAttribute("SessionFactory");?