use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method provisioningF_DeleteAccount.
@Test
public void provisioningF_DeleteAccount() {
// Create mapping for provisioning
SysSystemMappingDto mapping = this.createProvisionigMapping();
IdmRoleFilter filter = new IdmRoleFilter();
filter.setProperty(IdmRole_.code.getName());
filter.setValue(ROLE_NAME_TEN);
IdmRoleDto roleTen = roleService.find(filter, null).getContent().get(0);
Assert.assertNotNull(roleTen);
TestRoleResource ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
Assert.assertNotNull(ten);
// Delete IDM role (must invoke provisioning)
roleService.delete(roleTen);
ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
Assert.assertNull(ten);
// Delete role mapping
systemMappingService.delete(mapping);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method doStartSyncC_filterByToken.
@Test
public void doStartSyncC_filterByToken() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
IdmRoleFilter roleFilter = new IdmRoleFilter();
roleFilter.setProperty(IdmRole_.code.getName());
roleFilter.setValue("3");
IdmRoleDto roleThree = roleService.find(roleFilter, null).getContent().get(0);
Assert.assertNotNull(roleThree);
IdmFormValueDto changedRole = (IdmFormValueDto) formService.getValues(roleThree.getId(), IdmRole.class, "changed").get(0);
Assert.assertNotNull(changedRole);
// Set sync config
syncConfigCustom.setReconciliation(false);
syncConfigCustom.setCustomFilter(true);
syncConfigCustom.setFilterOperation(IcFilterOperationType.GREATER_THAN);
syncConfigCustom.setFilterAttribute(syncConfigCustom.getTokenAttribute());
syncConfigCustom.setToken((String) changedRole.getValue());
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigService.save(syncConfigCustom);
//
helper.startSynchronization(syncConfigCustom);
//
SysSyncLogFilter logFilter = new SysSyncLogFilter();
logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
Assert.assertEquals(1, logs.size());
SysSyncLogDto log = logs.get(0);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
actionLogFilter.setSynchronizationLogId(log.getId());
List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
Assert.assertEquals(1, actions.size());
SysSyncActionLogDto createEntityActionLog = actions.stream().filter(action -> {
return SynchronizationActionType.UPDATE_ENTITY == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(createEntityActionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(2, items.size());
SysSyncItemLogDto item = items.stream().filter(logitem -> {
return "4".equals(logitem.getIdentification());
}).findFirst().orElse(null);
Assert.assertNotNull("Log for role 4 must exist!", item);
item = items.stream().filter(logitem -> {
return "5".equals(logitem.getIdentification());
}).findFirst().orElse(null);
Assert.assertNotNull("Log for role 5 must exist!", item);
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class IdmRoleControllerRestTest method testFindByEnvironment.
@Test
public void testFindByEnvironment() {
IdmRoleDto roleOne = prepareDto();
roleOne.setCode(null);
roleOne.setBaseCode(getHelper().createName());
roleOne.setEnvironment(getHelper().createName());
IdmRoleDto roleOneCreated = createDto(roleOne);
IdmRoleDto roleTwo = prepareDto();
roleTwo.setCode(null);
roleTwo.setBaseCode(getHelper().createName());
roleTwo.setEnvironment(getHelper().createName());
roleTwo = createDto(roleTwo);
//
IdmRoleFilter filter = new IdmRoleFilter();
filter.setEnvironment(roleOne.getEnvironment());
List<IdmRoleDto> roles = find(filter);
Assert.assertEquals(1, roles.size());
Assert.assertTrue(roles.stream().anyMatch(r -> r.getId().equals(roleOneCreated.getId())));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class IdmRoleControllerRestTest method testFindByRoleComposition.
@Test
public void testFindByRoleComposition() {
IdmRoleDto roleRoot = createDto();
IdmRoleDto roleOne = createDto();
IdmRoleDto roleOneSub = createDto();
IdmRoleDto roleTwo = createDto();
getHelper().createRoleComposition(roleRoot, roleOne);
getHelper().createRoleComposition(roleRoot, roleTwo);
getHelper().createRoleComposition(roleOne, roleOneSub);
//
Assert.assertEquals(2, getDto(roleRoot.getId()).getChildrenCount());
//
IdmRoleFilter filter = new IdmRoleFilter();
filter.setParent(roleRoot.getId());
List<IdmRoleDto> roles = find(filter);
Assert.assertEquals(2, roles.size());
Assert.assertTrue(roles.stream().anyMatch(r -> r.getId().equals(roleOne.getId())));
Assert.assertTrue(roles.stream().anyMatch(r -> r.getId().equals(roleTwo.getId())));
//
filter.setParent(roleOne.getId());
roles = find(filter);
Assert.assertEquals(1, roles.size());
Assert.assertTrue(roles.stream().anyMatch(r -> r.getId().equals(roleOneSub.getId())));
//
filter.setParent(roleTwo.getId());
roles = find(filter);
Assert.assertTrue(roles.isEmpty());
}
Aggregations