### Question:
DefaultCategoryService implements CategoryService { @Override @Transactional public Category create(String text, User createdUser) { Category category = new CategoryImpl(); Date now = new Date(); category.setText(text); category.setCreatedDate(now); category.setCreatedUserId(createdUser.getId()); category.setLastModifiedDate(now); category.setLastModifiedUserId(createdUser.getId()); return categoryRepository.save(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 create() { final String NEW_CATEGORY_TEXT = "new category"; final String NEW_ID = "1"; Category expectedCategory = new CategoryImpl(); expectedCategory.setText(NEW_CATEGORY_TEXT); expect(repository.save(expectedCategory)).andDelegateTo(new MockCategoryRepository() { @Override public Category save(Category item) { item.setId(NEW_ID); return item; } }); replay(repository); Category wc = service.create(NEW_CATEGORY_TEXT, validCreatedUser); assertThat(wc.getText(), is(NEW_CATEGORY_TEXT)); assertThat(wc.getCreatedDate(), is(notNullValue(Date.class))); assertThat(wc.getCreatedDate(), is(wc.getLastModifiedDate())); assertThat(wc.getCreatedUserId(), is(VALID_CREATED_USER_ID)); assertThat(wc.getLastModifiedUserId(), is(VALID_CREATED_USER_ID)); assertThat(wc.getId(), is(NEW_ID)); verify(repository); }