use of org.springframework.data.history.Revision in project irida by phac-nml.
the class PasswordExpiryCheckerTest method testNonExpiredLogin.
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testNonExpiredLogin() {
Date today = new Date();
Calendar cal = new GregorianCalendar();
cal.setTime(today);
cal.add(Calendar.DAY_OF_MONTH, -1);
Date expiryDate = cal.getTime();
Revision<Integer, User> revision = new Revision(new RevisionMetadata() {
@Override
public Number getRevisionNumber() {
return 1L;
}
@Override
public DateTime getRevisionDate() {
return new DateTime(expiryDate.getTime());
}
@Override
public Object getDelegate() {
return null;
}
}, revUser);
when(userRepository.findRevisions(user.getId())).thenReturn(new Revisions<Integer, User>(Lists.newArrayList(revision)));
checker.check(user);
verify(userRepository).findRevisions(user.getId());
}
use of org.springframework.data.history.Revision in project irida by phac-nml.
the class ProjectServiceImplIT method testGetPagedProjectRevisions.
@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testGetPagedProjectRevisions() {
final String modifiedName = "creates a new revision";
final String modifiedDesc = "another new revision";
final Project p = projectService.read(1L);
p.setName(modifiedName);
projectService.update(p);
p.setProjectDescription(modifiedDesc);
projectService.update(p);
// reverse the order so that the latest revision is first in the list.
final Page<Revision<Integer, Project>> revisions = projectService.findRevisions(1L, new PageRequest(1, 1));
assertEquals("Should have 2 revisions.", 1, revisions.getContent().size());
final Revision<Integer, Project> mostRecent = revisions.iterator().next();
assertEquals("most recent revision should have project description change.", modifiedDesc, mostRecent.getEntity().getProjectDescription());
assertEquals("most recent revision should also have name changed.", modifiedName, mostRecent.getEntity().getName());
}
Aggregations