### Question:
DefaultCategoryService implements CategoryService { @Override @Transactional public Category update(String categoryId, String text, User lastModifiedUser) { Category category = categoryRepository.get(categoryId); category.setText(text); category.setLastModifiedDate(new Date()); category.setLastModifiedUserId(lastModifiedUser.getId()); categoryRepository.save(category); return category; } @Autowired  DefaultCategoryService(CategoryRepository categoryRepository); @Override Category get(String id); @Override List<Category> getAllList(); @Override SearchResult<Category> getAll(); @Override SearchResult<Category> getLimitedList(int offset, int pageSize); @Override @Transactional Category create(String text, User createdUser); @Override @Transactional Category update(String categoryId, String text, User lastModifiedUser); @Override @Transactional void delete(Category category);  }### Answer:
@Test public void update() { final String UPDATED_TEXT = "modified category"; Category expectedSaveCategory = new CategoryImpl(); expectedSaveCategory.setId(VALID_ID); expectedSaveCategory.setText(UPDATED_TEXT); expectedSaveCategory.setCreatedUserId(VALID_CREATED_USER_ID); expectedSaveCategory.setLastModifiedUserId(VALID_LAST_MODIFIED_USER_ID); expectedSaveCategory.setCreatedDate(VALID_CREATED_DATE); expectedSaveCategory.setLastModifiedDate(VALID_LAST_MODIFIED_DATE); expect(repository.get(VALID_ID)).andReturn(validCategory); expect(repository.save(expectedSaveCategory)).andReturn(expectedSaveCategory); replay(repository); Category updatedCategory = service.update(VALID_ID, UPDATED_TEXT, validLastModifiedUser); assertThat(updatedCategory.getId(), is(VALID_ID)); assertThat(updatedCategory.getText(), is(UPDATED_TEXT)); assertThat(updatedCategory.getCreatedUserId(), is(VALID_CREATED_USER_ID)); assertThat(updatedCategory.getLastModifiedUserId(), is(VALID_LAST_MODIFIED_USER_ID)); assertThat(updatedCategory.getLastModifiedDate().after(updatedCategory.getCreatedDate()), is(true)); verify(repository); }