@Test public void update_TodoEntryNotFound_ShouldThrowException() { TodoDTO updatedTodoEntry = new TodoDTOBuilder() .id(ID) .description(DESCRIPTION) .title(TITLE) .build(); when(repositoryMock.update(isA(Todo.class))).thenThrow(new TodoNotFoundException("")); catchException(service).update(updatedTodoEntry); assertThat(caughtException()).isExactlyInstanceOf(TodoNotFoundException.class); ArgumentCaptor<Todo> repositoryMethodArgument = ArgumentCaptor.forClass(Todo.class); verify(repositoryMock, times(1)).update(repositoryMethodArgument.capture()); verifyNoMoreInteractions(repositoryMock); Todo repositoryMethodArgumentValue = repositoryMethodArgument.getValue(); assertThatTodo(repositoryMethodArgumentValue) .hasDescription(DESCRIPTION) .hasId(ID) .hasTitle(TITLE) .creationTimeIsNotSet() .modificationTimeIsNotSet(); }
@Transactional @Override public TodoDTO update(TodoDTO dto) { LOGGER.info("Updating the information of a todo entry: {}", dto); Todo newInformation = createModel(dto); Todo updated = repository.update(newInformation); LOGGER.debug("Updated the information of a todo entry: {}", updated); return transformer.convert(updated, new TodoDTO()); }
RepositoryTodoCrudService implements TodoCrudService { @Transactional @Override public TodoDTO update(TodoDTO dto) { LOGGER.info("Updating the information of a todo entry: {}", dto); Todo newInformation = createModel(dto); Todo updated = repository.update(newInformation); LOGGER.debug("Updated the information of a todo entry: {}", updated); return transformer.convert(updated, new TodoDTO()); } }
RepositoryTodoCrudService implements TodoCrudService { @Transactional @Override public TodoDTO update(TodoDTO dto) { LOGGER.info("Updating the information of a todo entry: {}", dto); Todo newInformation = createModel(dto); Todo updated = repository.update(newInformation); LOGGER.debug("Updated the information of a todo entry: {}", updated); return transformer.convert(updated, new TodoDTO()); } @Autowired  RepositoryTodoCrudService(TodoRepository repository, JTransfo transformer); }
RepositoryTodoCrudService implements TodoCrudService { @Transactional @Override public TodoDTO update(TodoDTO dto) { LOGGER.info("Updating the information of a todo entry: {}", dto); Todo newInformation = createModel(dto); Todo updated = repository.update(newInformation); LOGGER.debug("Updated the information of a todo entry: {}", updated); return transformer.convert(updated, 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 @Override public TodoDTO update(TodoDTO dto) { LOGGER.info("Updating the information of a todo entry: {}", dto); Todo newInformation = createModel(dto); Todo updated = repository.update(newInformation); LOGGER.debug("Updated the information of a todo entry: {}", updated); return transformer.convert(updated, 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);  }