@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);
}