@Test public void update_TodoFound_ShouldReturnUpdatedTodo() throws TodoNotFoundException { TodoDTO dto = TodoTestUtil.createDTO(TodoTestUtil.ID, TodoTestUtil.DESCRIPTION_UPDATED, TodoTestUtil.TITLE_UPDATED); Todo model = TodoTestUtil.createModel(TodoTestUtil.ID, TodoTestUtil.DESCRIPTION, TodoTestUtil.TITLE); when(repositoryMock.findOne(dto.getId())).thenReturn(model); Todo actual = service.update(dto); verify(repositoryMock, times(1)).findOne(dto.getId()); verifyNoMoreInteractions(repositoryMock); verify(indexServiceMock, times(1)).update(model); verifyNoMoreInteractions(indexServiceMock); assertEquals(dto.getId(), actual.getId()); assertEquals(dto.getDescription(), actual.getDescription()); assertEquals(dto.getTitle(), actual.getTitle()); }
@PreAuthorize("hasPermission('Todo', 'update')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override public Todo update(TodoDTO updated) throws TodoNotFoundException { LOGGER.debug("Updating todo entry with information: {}", updated); Todo model = findById(updated.getId()); LOGGER.debug("Found a to-do entry: {}", model); model.update(updated.getDescription(), updated.getTitle()); indexService.update(model); return model; }
RepositoryTodoService implements TodoService { @PreAuthorize("hasPermission('Todo', 'update')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override public Todo update(TodoDTO updated) throws TodoNotFoundException { LOGGER.debug("Updating todo entry with information: {}", updated); Todo model = findById(updated.getId()); LOGGER.debug("Found a to-do entry: {}", model); model.update(updated.getDescription(), updated.getTitle()); indexService.update(model); return model; } }
RepositoryTodoService implements TodoService { @PreAuthorize("hasPermission('Todo', 'update')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override public Todo update(TodoDTO updated) throws TodoNotFoundException { LOGGER.debug("Updating todo entry with information: {}", updated); Todo model = findById(updated.getId()); LOGGER.debug("Found a to-do entry: {}", model); model.update(updated.getDescription(), updated.getTitle()); indexService.update(model); return model; }  }
RepositoryTodoService implements TodoService { @PreAuthorize("hasPermission('Todo', 'update')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override public Todo update(TodoDTO updated) throws TodoNotFoundException { LOGGER.debug("Updating todo entry with information: {}", updated); Todo model = findById(updated.getId()); LOGGER.debug("Found a to-do entry: {}", model); model.update(updated.getDescription(), updated.getTitle()); indexService.update(model); return model; }  @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', 'update')") @Transactional(rollbackFor = {TodoNotFoundException.class}) @Override public Todo update(TodoDTO updated) throws TodoNotFoundException { LOGGER.debug("Updating todo entry with information: {}", updated); Todo model = findById(updated.getId()); LOGGER.debug("Found a to-do entry: {}", model); model.update(updated.getDescription(), updated.getTitle()); indexService.update(model); return model; }  @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);  }