use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method changeResourceDataWrongEmail.
@Transactional
public void changeResourceDataWrongEmail() {
// Set wrong email to resource
TestResource one = entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME_ONE);
one.setEmail(IDENTITY_EMAIL_WRONG);
TestResource two = entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME_TWO);
two.setEmail(IDENTITY_EMAIL_WRONG);
// Change data on resource
entityManager.persist(one);
entityManager.persist(two);
}
use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method addIdentityThreeToResourceData.
@Transactional
public void addIdentityThreeToResourceData() {
// Change data on resource
// Insert data to testResource table
TestResource resourceUser = new TestResource();
resourceUser.setName("x" + IDENTITY_USERNAME_THREE);
resourceUser.setFirstname(IDENTITY_USERNAME_THREE);
resourceUser.setLastname(IDENTITY_USERNAME_THREE);
resourceUser.setEmail(IDENTITY_EMAIL_CORRECT);
resourceUser.setEavAttribute("3");
entityManager.persist(resourceUser);
}
use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method initResourceData.
@Transactional
public void initResourceData() {
// Delete all
Query q = entityManager.createNativeQuery("DELETE FROM test_resource");
q.executeUpdate();
// Insert data to testResource table
LocalDateTime paste = LocalDateTime.now().minusYears(1);
LocalDateTime future = paste.plusYears(2);
TestResource resourceUserOne = new TestResource();
resourceUserOne.setName("x" + IDENTITY_USERNAME_ONE);
resourceUserOne.setFirstname(IDENTITY_USERNAME_ONE);
resourceUserOne.setLastname(IDENTITY_USERNAME_ONE);
resourceUserOne.setEmail(IDENTITY_EMAIL_CORRECT);
resourceUserOne.setModified(paste);
resourceUserOne.setEavAttribute("1");
entityManager.persist(resourceUserOne);
TestResource resourceUserTwo = new TestResource();
resourceUserTwo.setName("x" + IDENTITY_USERNAME_TWO);
resourceUserTwo.setFirstname(IDENTITY_USERNAME_TWO);
resourceUserTwo.setLastname(IDENTITY_USERNAME_TWO);
resourceUserTwo.setEmail(IDENTITY_EMAIL_CORRECT);
resourceUserTwo.setModified(future);
resourceUserTwo.setEavAttribute("2");
entityManager.persist(resourceUserTwo);
}
use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangeSingleAttribute.
@Test
public void doIdentityProvisioningChangeSingleAttribute() {
IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
identity.setFirstName(IDENTITY_CHANGED_FIRST_NAME);
identity = idmIdentityService.save(identity);
Assert.assertEquals("Identity must have this first name!", IDENTITY_CHANGED_FIRST_NAME, identity.getFirstName());
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
filter.setSystemId(systemService.getByCode(SYSTEM_NAME).getId());
AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
AccAccountDto account = accountService.get(accountIdentityOne.getAccount());
SysSystemDto system = DtoUtils.getEmbedded(account, AccAccount_.system, SysSystemDto.class);
SysSystemEntityDto systemEntity = DtoUtils.getEmbedded(account, AccAccount_.systemEntity, SysSystemEntityDto.class);
SysSystemAttributeMappingFilter attributeFilter = new SysSystemAttributeMappingFilter();
attributeFilter.setSystemId(system.getId());
attributeFilter.setIdmPropertyName("firstName");
TestResource resourceAccount = entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME);
Assert.assertNotNull("Idenitity have to exists on target system (after account management)", resourceAccount);
Assert.assertEquals("Account on target system, must have same first name as Identity", IDENTITY_CHANGED_FIRST_NAME, resourceAccount.getFirstname());
provisioningService.doProvisioningForAttribute(systemEntity, systemAttributeMappingService.find(attributeFilter, null).getContent().get(0), IDENTITY_USERNAME, ProvisioningOperationType.UPDATE, identity);
resourceAccount = entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME);
Assert.assertNotNull("Idenitity have to exists on target system (after account management)", resourceAccount);
Assert.assertEquals("Account on target system, must have changed first name!", IDENTITY_USERNAME, resourceAccount.getFirstname());
}
use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangeManagersContract.
/**
* Call provisioning for subordinates, after managers's contract changes - filled managers could be provisioned
*/
@Test
public void doIdentityProvisioningChangeManagersContract() {
IdmIdentityDto managerOne = createIdentity();
IdmIdentityDto subordinateOne = createIdentity();
IdmTreeNodeDto managerOnePosition = createTreeNode(null);
IdmIdentityContractDto managersContract = createIdentityContact(managerOne, managerOnePosition);
IdmTreeNodeDto subordinateOnePositionOne = createTreeNode(managerOnePosition);
createIdentityContact(subordinateOne, subordinateOnePositionOne);
AccIdentityAccountDto subordinateAccount = prepareAccount(subordinateOne);
//
provisioningService.doProvisioning(DtoUtils.getEmbedded(subordinateAccount, AccIdentityAccount_.identity, IdmIdentityDto.class));
//
TestResource account = entityManager.find(TestResource.class, accountService.get(subordinateAccount.getAccount()).getUid());
Assert.assertNotNull(account);
Assert.assertEquals(subordinateOne.getFirstName(), account.getFirstname());
//
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setSubordinatesFor(managerOne.getId());
List<IdmIdentityDto> subordinates = idmIdentityService.find(filter, null).getContent();
Assert.assertEquals(1, subordinates.size());
Assert.assertEquals(subordinateOne.getId(), subordinates.get(0).getId());
//
// change subordinate
subordinateOne.setFirstName("first-name-change-one");
subordinateOne = idmIdentityService.saveInternal(subordinateOne);
//
// change managers contract
managersContract.setWorkPosition(null);
managersContract = identityContractService.save(managersContract);
//
account = entityManager.find(TestResource.class, accountService.get(subordinateAccount.getAccount()).getUid());
Assert.assertNotNull(account);
Assert.assertEquals(subordinateOne.getFirstName(), account.getFirstname());
subordinates = idmIdentityService.find(filter, null).getContent();
Assert.assertEquals(0, subordinates.size());
//
// change subordinate again
subordinateOne.setFirstName("first-name-change-two");
subordinateOne = idmIdentityService.saveInternal(subordinateOne);
//
managersContract.setWorkPosition(managerOnePosition.getId());
managersContract = identityContractService.save(managersContract);
//
account = entityManager.find(TestResource.class, accountService.get(subordinateAccount.getAccount()).getUid());
Assert.assertNotNull(account);
Assert.assertEquals(subordinateOne.getFirstName(), account.getFirstname());
subordinates = idmIdentityService.find(filter, null).getContent();
Assert.assertEquals(1, subordinates.size());
Assert.assertEquals(subordinateOne.getId(), subordinates.get(0).getId());
}
Aggregations