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;
}
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);
}
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());
}
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());
}
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())));
}
Aggregations