use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningStrategySendOnlyIfNotNull.
@Test
public void doIdentityProvisioningStrategySendOnlyIfNotNull() {
IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
// Init value check
TestResource resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
Assert.assertEquals(EMAIL_TWO, resourceAccoutn.getEmail());
SysSystemAttributeMappingFilter filterSchemaAttr = new SysSystemAttributeMappingFilter();
filterSchemaAttr.setIdmPropertyName("email");
filterSchemaAttr.setSystemId(accountService.get(accountIdentityOne.getAccount()).getSystem());
SysSystemAttributeMappingDto attributeHandling = systemAttributeMappingService.find(filterSchemaAttr, null).getContent().get(0);
attributeHandling.setEntityAttribute(true);
attributeHandling.setStrategyType(AttributeMappingStrategyType.SET);
attributeHandling.setSendOnlyIfNotNull(true);
attributeHandling.setTransformToResourceScript("return null");
systemAttributeMappingService.save(attributeHandling);
// Do provisioning
provisioningService.doProvisioning(identity);
// Email strategy is SendOnlyIfNotNull ... email in account must have old value
resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
Assert.assertEquals(EMAIL_TWO, resourceAccoutn.getEmail());
attributeHandling.setStrategyType(AttributeMappingStrategyType.SET);
attributeHandling.setTransformToResourceScript("return \"\";");
systemAttributeMappingService.save(attributeHandling);
// Do provisioning
provisioningService.doProvisioning(identity);
// Email strategy is SendOnlyIfNotNull (value is empty string) ... email in account must have old value
resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
Assert.assertEquals(EMAIL_TWO, resourceAccoutn.getEmail());
attributeHandling.setStrategyType(AttributeMappingStrategyType.SET);
attributeHandling.setTransformToResourceScript("return \"" + EMAIL_ONE + "\";");
systemAttributeMappingService.save(attributeHandling);
// Do provisioning
provisioningService.doProvisioning(identity);
// Email strategy is SendOnlyIfNotNull (value is not null and not empty)... email in account must have new value
resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
Assert.assertEquals(EMAIL_ONE, resourceAccoutn.getEmail());
}
use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangeAccount.
@Test
public void doIdentityProvisioningChangeAccount() {
IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
TestResource createdAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
identity.setFirstName(IDENTITY_CHANGED_FIRST_NAME);
identity = idmIdentityService.save(identity);
Assert.assertNotEquals(identity.getFirstName(), createdAccount.getFirstname());
provisioningService.doProvisioning(identity);
TestResource changedAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
Assert.assertNotNull(changedAccount);
Assert.assertEquals(identity.getFirstName(), changedAccount.getFirstname());
}
use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningAddAccount.
@Test
public void doIdentityProvisioningAddAccount() {
initData();
IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
provisioningService.doProvisioning(DtoUtils.getEmbedded(accountIdentityOne, AccIdentityAccount_.identity, IdmIdentityDto.class));
TestResource createdAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
Assert.assertNotNull(createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
}
use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningZRemoveAccount.
@Test
public void doIdentityProvisioningZRemoveAccount() {
IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
// Delete account
accountService.deleteById(accountIdentityOne.getAccount());
Assert.assertNull(accountService.get(accountIdentityOne.getAccount()));
}
use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.
the class IdentityAccountSaveProcessor method findIdentityAccounts.
private List<AccIdentityAccountDto> findIdentityAccounts(UUID account) {
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setAccountId(account);
filter.setOwnership(Boolean.TRUE);
List<AccIdentityAccountDto> identityAccounts = service.find(filter, null).getContent();
return identityAccounts;
}
Aggregations