use of eu.bcvsolutions.idm.core.api.entity.BaseEntity in project CzechIdMng by bcvsolutions.
the class DefaultAuditServiceTest method testFindRevision.
@Test
@Transactional
public void testFindRevision() {
IdmRole roleRevision = auditService.findRevision(IdmRole.class, UUID.randomUUID(), 123456l);
assertEquals(null, roleRevision);
List<IdmAuditDto> result = auditService.find(null).getContent();
// test only first and second
try {
IdmAuditDto idmAudit = result.get(0);
BaseEntity object = (BaseEntity) auditService.findRevision(Class.forName(idmAudit.getType()), idmAudit.getEntityId(), (Long) idmAudit.getId());
if (object != null) {
assertEquals((UUID) object.getId(), idmAudit.getEntityId());
Class.forName(idmAudit.getType()).cast(object);
}
// second
idmAudit = result.get(1);
object = (BaseEntity) auditService.findRevision(Class.forName(idmAudit.getType()), idmAudit.getEntityId(), (Long) idmAudit.getId());
if (object != null) {
assertEquals((UUID) object.getId(), idmAudit.getEntityId());
Class.forName(idmAudit.getType()).cast(object);
}
} catch (ClassNotFoundException e) {
fail(e.getLocalizedMessage());
}
/*
* IdmRole roleRevision2 = auditService.getPreviousVersion(roleRevision,
* (Long)audit.getId()); assertNotEquals(null, roleRevision2);
* assertEquals("audit_test_role", roleRevision2.getName());
*/
}
Aggregations