Search in sources :

Example 6 with BaseEntity

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());
		 */
}
Also used : IdmAuditDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmAuditDto) BaseEntity(eu.bcvsolutions.idm.core.api.entity.BaseEntity) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

BaseEntity (eu.bcvsolutions.idm.core.api.entity.BaseEntity)6 Embedded (eu.bcvsolutions.idm.core.api.domain.Embedded)2 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)2 Field (java.lang.reflect.Field)2 UUID (java.util.UUID)2 PropertyMapping (org.modelmapper.spi.PropertyMapping)2 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)1 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)1 IdmAuditDto (eu.bcvsolutions.idm.core.api.audit.dto.IdmAuditDto)1 Identifiable (eu.bcvsolutions.idm.core.api.domain.Identifiable)1 AbstractDto (eu.bcvsolutions.idm.core.api.dto.AbstractDto)1 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)1 IdmRole (eu.bcvsolutions.idm.core.model.entity.IdmRole)1 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)1 Test (org.junit.Test)1 Transactional (org.springframework.transaction.annotation.Transactional)1