### Question:
TaskPersisterJpa implements TaskPersister { @Override public TaskStatusInfo getTaskStatusInfo(String id) { return em.find(TaskStatusInfo.class, id); } TaskPersisterJpa(); @Override String createTask(String taskType, Map<String, Object> taskConfig); @Override List<TaskStatusInfo> listTasks(String taskTypeFilter, List<TaskStatus> taskStatusFilter, int from, int size); @Override TaskStatusInfo getTaskStatusInfo(String id); @Override boolean markTaskToBeCancelled(String id); @Override boolean changeTaskStatus(String id, TaskStatus taskStatusNew, String message); @Override void writeTaskLog(String id, String message); @Override TaskStatusInfo getTaskToRun(String nodeId); @Override void heartbeat(String nodeId, Set<String> runningTasksId, long failoverTimeout); static final long FAILOVER_DELAY_10; static final long FAILOVER_DELAY_30; static final long FAILOVER_DELAY_100; }### Answer:
@Test public void getTaskStatusInfo() { TaskPersisterJpa tested = getTested(); { Mockito.when(tested.em.find(TaskStatusInfo.class, "myid")).thenReturn(null); Assert.assertNull(tested.getTaskStatusInfo("myid")); Mockito.verify(tested.em).find(TaskStatusInfo.class, "myid"); } { Mockito.reset(tested.em); final TaskStatusInfo ret = createTaskStatusInfoWithStatus(TaskStatus.FAILOVER); Mockito.when(tested.em.find(TaskStatusInfo.class, "myid")).thenReturn(ret); Assert.assertEquals(ret, tested.getTaskStatusInfo("myid")); Mockito.verify(tested.em).find(TaskStatusInfo.class, "myid"); } }