@Test(expected = TodoNotFoundException.class) public void deleteById_ToDoIsNotFound_ShouldThrowException() throws TodoNotFoundException { when(repositoryMock.findOne(TodoTestUtil.ID)).thenReturn(null); service.deleteById(TodoTestUtil.ID); verify(repositoryMock, times(1)).findOne(TodoTestUtil.ID); verifyNoMoreInteractions(repositoryMock); verifyZeroInteractions(indexServiceMock); }
@PreAuthorize("hasPermission('Todo', 'delete')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override public Todo deleteById(Long id) throws TodoNotFoundException { LOGGER.debug("Deleting a to-do entry with id: {}", id); Todo deleted = findById(id); LOGGER.debug("Deleting to-do entry: {}", deleted); repository.delete(deleted); indexService.deleteFromIndex(id); return deleted; }
RepositoryTodoService implements TodoService { @PreAuthorize("hasPermission('Todo', 'delete')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override public Todo deleteById(Long id) throws TodoNotFoundException { LOGGER.debug("Deleting a to-do entry with id: {}", id); Todo deleted = findById(id); LOGGER.debug("Deleting to-do entry: {}", deleted); repository.delete(deleted); indexService.deleteFromIndex(id); return deleted; } }
RepositoryTodoService implements TodoService { @PreAuthorize("hasPermission('Todo', 'delete')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override public Todo deleteById(Long id) throws TodoNotFoundException { LOGGER.debug("Deleting a to-do entry with id: {}", id); Todo deleted = findById(id); LOGGER.debug("Deleting to-do entry: {}", deleted); repository.delete(deleted); indexService.deleteFromIndex(id); return deleted; }  }
RepositoryTodoService implements TodoService { @PreAuthorize("hasPermission('Todo', 'delete')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override public Todo deleteById(Long id) throws TodoNotFoundException { LOGGER.debug("Deleting a to-do entry with id: {}", id); Todo deleted = findById(id); LOGGER.debug("Deleting to-do entry: {}", deleted); repository.delete(deleted); indexService.deleteFromIndex(id); return deleted; }  @PreAuthorize("hasPermission('Todo', 'add')") @Transactional @Override Todo add(TodoDTO added); @PreAuthorize("hasPermission('Todo', 'search')") @Override long countSearchResults(String searchTerm); @PreAuthorize("hasPermission('Todo', 'delete')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override Todo deleteById(Long id); @PreAuthorize("hasPermission('Todo', 'list')") @Transactional(readOnly = true) @Override List<Todo> findAll(); @PreAuthorize("hasPermission('Todo', 'find')") @Transactional(readOnly = true, rollbackFor = {TodoNotFoundException.class}) @Override Todo findById(Long id); @PreAuthorize("hasPermission('Todo', 'update')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override Todo update(TodoDTO updated); @PreAuthorize("hasPermission('Todo', 'search')") @Override List<TodoDocument> search(String searchTerm, Pageable page); }
RepositoryTodoService implements TodoService { @PreAuthorize("hasPermission('Todo', 'delete')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override public Todo deleteById(Long id) throws TodoNotFoundException { LOGGER.debug("Deleting a to-do entry with id: {}", id); Todo deleted = findById(id); LOGGER.debug("Deleting to-do entry: {}", deleted); repository.delete(deleted); indexService.deleteFromIndex(id); return deleted; }  @PreAuthorize("hasPermission('Todo', 'add')") @Transactional @Override Todo add(TodoDTO added); @PreAuthorize("hasPermission('Todo', 'search')") @Override long countSearchResults(String searchTerm); @PreAuthorize("hasPermission('Todo', 'delete')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override Todo deleteById(Long id); @PreAuthorize("hasPermission('Todo', 'list')") @Transactional(readOnly = true) @Override List<Todo> findAll(); @PreAuthorize("hasPermission('Todo', 'find')") @Transactional(readOnly = true, rollbackFor = {TodoNotFoundException.class}) @Override Todo findById(Long id); @PreAuthorize("hasPermission('Todo', 'update')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override Todo update(TodoDTO updated); @PreAuthorize("hasPermission('Todo', 'search')") @Override List<TodoDocument> search(String searchTerm, Pageable page);  }