@Test public void findById_TodoIsFound_ShouldReturnTodo() throws TodoNotFoundException { Todo model = TodoTestUtil.createModel(TodoTestUtil.ID, TodoTestUtil.DESCRIPTION, TodoTestUtil.TITLE); when(repositoryMock.findOne(TodoTestUtil.ID)).thenReturn(model); Todo actual = service.findById(TodoTestUtil.ID); verify(repositoryMock, times(1)).findOne(TodoTestUtil.ID); verifyNoMoreInteractions(repositoryMock); verifyZeroInteractions(indexServiceMock); assertEquals(model, actual); }
@PreAuthorize("hasPermission('Todo', 'find')") @Transactional(readOnly = true, rollbackFor = {TodoNotFoundException.class}) @Override public Todo findById(Long id) throws TodoNotFoundException { LOGGER.debug("Finding a to-do entry with id: {}", id); Todo found = repository.findOne(id); LOGGER.debug("Found to-do entry: {}", found); if (found == null) { throw new TodoNotFoundException("No to-entry found with id: " + id); } return found; }
RepositoryTodoService implements TodoService { @PreAuthorize("hasPermission('Todo', 'find')") @Transactional(readOnly = true, rollbackFor = {TodoNotFoundException.class}) @Override public Todo findById(Long id) throws TodoNotFoundException { LOGGER.debug("Finding a to-do entry with id: {}", id); Todo found = repository.findOne(id); LOGGER.debug("Found to-do entry: {}", found); if (found == null) { throw new TodoNotFoundException("No to-entry found with id: " + id); } return found; } }
RepositoryTodoService implements TodoService { @PreAuthorize("hasPermission('Todo', 'find')") @Transactional(readOnly = true, rollbackFor = {TodoNotFoundException.class}) @Override public Todo findById(Long id) throws TodoNotFoundException { LOGGER.debug("Finding a to-do entry with id: {}", id); Todo found = repository.findOne(id); LOGGER.debug("Found to-do entry: {}", found); if (found == null) { throw new TodoNotFoundException("No to-entry found with id: " + id); } return found; }  }
RepositoryTodoService implements TodoService { @PreAuthorize("hasPermission('Todo', 'find')") @Transactional(readOnly = true, rollbackFor = {TodoNotFoundException.class}) @Override public Todo findById(Long id) throws TodoNotFoundException { LOGGER.debug("Finding a to-do entry with id: {}", id); Todo found = repository.findOne(id); LOGGER.debug("Found to-do entry: {}", found); if (found == null) { throw new TodoNotFoundException("No to-entry found with id: " + id); } return found; }  @PreAuthorize("hasPermission('Todo', 'add')") @Transactional @Override Todo add(TodoDTO added); @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); }
RepositoryTodoService implements TodoService { @PreAuthorize("hasPermission('Todo', 'find')") @Transactional(readOnly = true, rollbackFor = {TodoNotFoundException.class}) @Override public Todo findById(Long id) throws TodoNotFoundException { LOGGER.debug("Finding a to-do entry with id: {}", id); Todo found = repository.findOne(id); LOGGER.debug("Found to-do entry: {}", found); if (found == null) { throw new TodoNotFoundException("No to-entry found with id: " + id); } return found; }  @PreAuthorize("hasPermission('Todo', 'add')") @Transactional @Override Todo add(TodoDTO added); @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);  }