访问DAO类时获取null异常

时间:2019-08-19 08:48:40

标签: spring-boot jpa junit

public Task findTaskById(Long id) {
    if (taskDAO.existsById(id)) {
        return taskDAO.findById(id).get();
    }
    return null;
}

@Test
public void test_findTaskById() {
    taskDAO = Mockito.mock(TaskDAO.class, Mockito.RETURNS_DEEP_STUBS);
    when(taskDAO.existsById(12345L)).thenReturn(true);

    instance.findTaskById(1234567890L);
}

taskDAO为空。需要帮助以获取taskDAO的一些模拟值

0 个答案:

没有答案