@Test public void delete_TodoEntryNotFound_ShouldThrowException() { when(repositoryMock.delete(ID)).thenThrow(new TodoNotFoundException("")); catchException(service).delete(ID); assertThat(caughtException()).isExactlyInstanceOf(TodoNotFoundException.class); verify(repositoryMock, times(1)).delete(ID); verifyNoMoreInteractions(repositoryMock); }
@Transactional @Override public TodoDTO delete(Long id) { LOGGER.info("Deleting todo entry with id: {}", id); Todo deleted = repository.delete(id); LOGGER.info("Deleted to entry with id: {}", id); return transformer.convert(deleted, new TodoDTO()); }
RepositoryTodoCrudService implements TodoCrudService { @Transactional @Override public TodoDTO delete(Long id) { LOGGER.info("Deleting todo entry with id: {}", id); Todo deleted = repository.delete(id); LOGGER.info("Deleted to entry with id: {}", id); return transformer.convert(deleted, new TodoDTO()); } }
RepositoryTodoCrudService implements TodoCrudService { @Transactional @Override public TodoDTO delete(Long id) { LOGGER.info("Deleting todo entry with id: {}", id); Todo deleted = repository.delete(id); LOGGER.info("Deleted to entry with id: {}", id); return transformer.convert(deleted, new TodoDTO()); } @Autowired  RepositoryTodoCrudService(TodoRepository repository, JTransfo transformer); }
RepositoryTodoCrudService implements TodoCrudService { @Transactional @Override public TodoDTO delete(Long id) { LOGGER.info("Deleting todo entry with id: {}", id); Todo deleted = repository.delete(id); LOGGER.info("Deleted to entry with id: {}", id); return transformer.convert(deleted, 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 delete(Long id) { LOGGER.info("Deleting todo entry with id: {}", id); Todo deleted = repository.delete(id); LOGGER.info("Deleted to entry with id: {}", id); return transformer.convert(deleted, 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);  }