@Test
public void update() {
final String UPDATED_TEXT = "modified category";
Category expectedSaveCategory = new Category();
expectedSaveCategory.setEntityId(VALID_ID);
expectedSaveCategory.setText(UPDATED_TEXT);
expectedSaveCategory.setCreatedUser(validCreatedUser);
expectedSaveCategory.setLastModifiedUser(validLastModifiedUser);
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.getEntityId(), is(VALID_ID));
assertThat(updatedCategory.getText(), is(UPDATED_TEXT));
assertThat(updatedCategory.getCreatedUser(), is(validCreatedUser));
assertThat(updatedCategory.getLastModifiedUser(), is(validLastModifiedUser));
assertThat(updatedCategory.getLastModifiedDate().after(updatedCategory.getCreatedDate()), is(true));
verify(repository);
}