RepositoryTodoCrudService implements TodoCrudService { @Transactional(readOnly = true) @Override public List<TodoDTO> findAll() { LOGGER.info("Finding all todo entries."); List<Todo> todoEntries = repository.findAll(); LOGGER.debug("Found {} todo entries.", todoEntries.size()); return transformer.convertList(todoEntries, TodoDTO.class); } @Autowired  RepositoryTodoCrudService(TodoRepository repository, JTransfo transformer); @Transactional @Override TodoDTO add(TodoDTO dto); @Transactional @Override TodoDTO delete(Long id); @Transactional(readOnly = true) @Override List<TodoDTO> findAll(); @Transactional(readOnly = true) @Override TodoDTO findById(Long id); @Transactional @Override TodoDTO update(TodoDTO dto);  }
@Test public void findAll_OneTodoEntryFound_ShouldReturnTheFoundTodoEntry() { Todo foundTodoEntry = Todo.getBuilder(TITLE) .creationTime(CREATION_TIME) .description(DESCRIPTION) .id(ID) .modificationTime(MODIFICATION_TIME) .build(); when(repositoryMock.findAll()).thenReturn(Arrays.asList(foundTodoEntry)); List<TodoDTO> returnedTodoEntries = service.findAll(); verify(repositoryMock, times(1)).findAll(); verifyNoMoreInteractions(repositoryMock); assertThat(returnedTodoEntries).hasSize(1); TodoDTO returnedTodoEntry = returnedTodoEntries.get(0); assertThatTodoDTO(returnedTodoEntry) .hasDescription(DESCRIPTION) .hasId(ID) .hasTitle(TITLE) .wasCreatedAt(CREATION_TIME_STRING) .wasModifiedAt(MODIFICATION_TIME_STRING); }