@Test public void findById_TodoEntryFound_ShouldReturnFoundTodoEntry() { Todo foundTodoEntry = Todo.getBuilder(TITLE) .creationTime(CREATION_TIME) .description(DESCRIPTION) .id(ID) .modificationTime(MODIFICATION_TIME) .build(); when(repositoryMock.findById(ID)).thenReturn(foundTodoEntry); TodoDTO returnedTodoEntry = service.findById(ID); verify(repositoryMock, times(1)).findById(ID); verifyNoMoreInteractions(repositoryMock); assertThatTodoDTO(returnedTodoEntry) .hasId(ID) .hasDescription(DESCRIPTION) .hasTitle(TITLE) .wasCreatedAt(CREATION_TIME_STRING) .wasModifiedAt(MODIFICATION_TIME_STRING); }
@Transactional(readOnly = true) @Override public TodoDTO findById(Long id) { LOGGER.info("Finding to entry with id: {}", id); Todo found = repository.findById(id); LOGGER.info("Found todo entry: {}", found); return transformer.convert(found, new TodoDTO()); }
RepositoryTodoCrudService implements TodoCrudService { @Transactional(readOnly = true) @Override public TodoDTO findById(Long id) { LOGGER.info("Finding to entry with id: {}", id); Todo found = repository.findById(id); LOGGER.info("Found todo entry: {}", found); return transformer.convert(found, new TodoDTO()); } }
RepositoryTodoCrudService implements TodoCrudService { @Transactional(readOnly = true) @Override public TodoDTO findById(Long id) { LOGGER.info("Finding to entry with id: {}", id); Todo found = repository.findById(id); LOGGER.info("Found todo entry: {}", found); return transformer.convert(found, new TodoDTO()); } @Autowired  RepositoryTodoCrudService(TodoRepository repository, JTransfo transformer); }
RepositoryTodoCrudService implements TodoCrudService { @Transactional(readOnly = true) @Override public TodoDTO findById(Long id) { LOGGER.info("Finding to entry with id: {}", id); Todo found = repository.findById(id); LOGGER.info("Found todo entry: {}", found); return transformer.convert(found, new TodoDTO()); } @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); }
RepositoryTodoCrudService implements TodoCrudService { @Transactional(readOnly = true) @Override public TodoDTO findById(Long id) { LOGGER.info("Finding to entry with id: {}", id); Todo found = repository.findById(id); LOGGER.info("Found todo entry: {}", found); return transformer.convert(found, new TodoDTO()); } @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);  }