Search in sources :

Example 36 with IdmIdentity

use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.

the class OAuthAuthenticationManagerTest method getAuthChange.

private IdmAuthorityChange getAuthChange(IdmIdentityDto i, DateTime dt) {
    IdmAuthorityChange c = new IdmAuthorityChange();
    c.setIdentity(new IdmIdentity(i.getId()));
    c.setAuthChangeTimestamp(dt);
    return c;
}
Also used : IdmAuthorityChange(eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity)

Example 37 with IdmIdentity

use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.

the class ParameterConverterUnitTest method testEntityParameter.

@Test
public void testEntityParameter() {
    Map<String, Object> parameters = new HashMap<>();
    String value = "admin";
    IdmIdentity identity = new IdmIdentity(UUID.randomUUID());
    when(entityLookupService.lookupEntity(IdmIdentity.class, value)).thenReturn(identity);
    parameters.put(PARAMETER_NAME, value);
    // 
    assertEquals(identity, parameterConverter.toEntity(parameters, PARAMETER_NAME, IdmIdentity.class));
    // 
    verify(entityLookupService).lookupEntity(IdmIdentity.class, value);
}
Also used : HashMap(java.util.HashMap) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractVerifiableUnitTest(eu.bcvsolutions.idm.test.api.AbstractVerifiableUnitTest) Test(org.junit.Test)

Example 38 with IdmIdentity

use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.

the class AbstractEntityUnitTest method testEqualsAndHashCode.

@Test
public void testEqualsAndHashCode() {
    AbstractEntity entityOne = new IdmIdentity();
    AbstractEntity entityTwo = new IdmIdentity();
    // 
    Assert.assertFalse(entityOne.equals(entityTwo));
    Assert.assertFalse(entityOne.equals(null));
    Assert.assertEquals(entityOne.hashCode(), entityTwo.hashCode());
    // 
    Object mockResource = Mockito.mock(IdmIdentity.class);
    // 
    Assert.assertTrue(mockResource.equals(mockResource));
    Assert.assertFalse(mockResource.equals(null));
    // 
    entityOne = new IdmIdentity(UUID.randomUUID());
    entityTwo = new IdmIdentity(UUID.randomUUID());
    // 
    Assert.assertFalse(entityOne.equals(entityTwo));
    Assert.assertNotEquals(entityOne.hashCode(), entityTwo.hashCode());
    Assert.assertNotEquals(entityOne.toString(), entityTwo.toString());
    // 
    entityOne = new IdmIdentity(UUID.randomUUID());
    entityTwo = new IdmIdentity(entityOne.getId());
    // 
    Assert.assertTrue(entityOne.equals(entityTwo));
    Assert.assertEquals(entityOne.hashCode(), entityTwo.hashCode());
    Assert.assertEquals(entityOne.toString(), entityTwo.toString());
    // 
    entityOne = new IdmIdentity(UUID.randomUUID());
    entityTwo = new IdmIdentity();
    // 
    Assert.assertFalse(entityOne.equals(entityTwo));
    Assert.assertNotEquals(entityOne.hashCode(), entityTwo.hashCode());
    Assert.assertNotEquals(entityOne.toString(), entityTwo.toString());
    // 
    entityOne = new IdmIdentity();
    entityTwo = new IdmIdentity(UUID.randomUUID());
    // 
    Assert.assertFalse(entityOne.equals(entityTwo));
    Assert.assertNotEquals(entityOne.hashCode(), entityTwo.hashCode());
    Assert.assertNotEquals(entityOne.toString(), entityTwo.toString());
}
Also used : IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest) Test(org.junit.Test)

Example 39 with IdmIdentity

use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.

the class DefaultAuditServiceIntegrationTest method testFindLastPersistedVersion.

@Test
public void testFindLastPersistedVersion() {
    IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
    identity.setUsername(getHelper().createName());
    identity = identityService.save(identity);
    identity.setUsername(getHelper().createName());
    identity = identityService.save(identity);
    identityService.delete(identity);
    // 
    Assert.assertNull(identityService.get(identity));
    Assert.assertNull(auditService.findLastRevisionNumber(IdmIdentity.class, UUID.randomUUID()));
    Assert.assertNull(auditService.findLastPersistedVersion(IdmIdentity.class, UUID.randomUUID()));
    Assert.assertNotNull(auditService.findLastRevisionNumber(IdmIdentity.class, identity.getId()));
    // 
    IdmIdentity findLastPersistedVersion = auditService.findLastPersistedVersion(IdmIdentity.class, identity.getId());
    Assert.assertNotNull(findLastPersistedVersion);
    Assert.assertEquals(identity.getUsername(), findLastPersistedVersion.getUsername());
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 40 with IdmIdentity

use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.

the class IdentityGuaranteesForRoleFilterIntegrationTest method testFind.

@Test
public void testFind() {
    // prepare data
    IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identityThree = getHelper().createIdentity((GuardedString) null);
    IdmRoleDto role = getHelper().createRole();
    IdmRoleDto roleGuarantee = getHelper().createRole();
    getHelper().createRoleGuarantee(role, identityOne);
    getHelper().createRoleGuaranteeRole(role, roleGuarantee);
    getHelper().createIdentityRole(identityThree, roleGuarantee);
    getHelper().createIdentityRole(identityTwo, role);
    // 
    IdmIdentityFilter dataFilter = new IdmIdentityFilter();
    dataFilter.setGuaranteesForRole(role.getId());
    List<IdmIdentity> identities = filter.find(dataFilter, null).getContent();
    // 
    Assert.assertEquals(2, identities.size());
    Assert.assertTrue(identities.stream().anyMatch(i -> i.getId().equals(identityOne.getId())));
    Assert.assertTrue(identities.stream().anyMatch(i -> i.getId().equals(identityThree.getId())));
}
Also used : List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) Transactional(org.springframework.transaction.annotation.Transactional) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)58 Test (org.junit.Test)44 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)28 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)20 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)18 AbstractUnitTest (eu.bcvsolutions.idm.test.api.AbstractUnitTest)13 Transactional (org.springframework.transaction.annotation.Transactional)11 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)9 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)9 IdmIdentityService (eu.bcvsolutions.idm.core.api.service.IdmIdentityService)7 DataFilter (eu.bcvsolutions.idm.core.api.dto.filter.DataFilter)6 List (java.util.List)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 IdmIdentityContract (eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract)5 Assert (org.junit.Assert)5 IdmAuthorityChange (eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange)4 UUID (java.util.UUID)4 Identifiable (eu.bcvsolutions.idm.core.api.domain.Identifiable)3 IdmEntityEventDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto)3 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)3