use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class RoleDeleteBulkActionIntegrationTest method processBulkActionByFilterWithRemove.
@Test
public void processBulkActionByFilterWithRemove() {
String testDescription = "bulkActionName" + System.currentTimeMillis();
List<IdmRoleDto> roles = this.createRoles(5);
IdmRoleDto removedRole = roles.get(0);
IdmRoleDto removedRole2 = roles.get(1);
for (IdmRoleDto role : roles) {
role.setDescription(testDescription);
role = roleService.save(role);
}
IdmRoleFilter filter = new IdmRoleFilter();
filter.setValue(testDescription);
filter.setProperty(IdmRole_.description.getName());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmRole.class, RoleDeleteBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
bulkAction.setRemoveIdentifiers(Sets.newHashSet(removedRole.getId(), removedRole2.getId()));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 3l, null, null);
Set<UUID> ids = getIdFromList(roles);
for (UUID id : ids) {
IdmRoleDto dto = roleService.get(id);
if (id.equals(removedRole.getId()) || id.equals(removedRole2.getId())) {
assertNotNull(dto);
continue;
}
assertNull(dto);
}
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleServiceIntegrationTest method testCorrelableFilter.
/**
* Test find role by all string fields
*/
@Test
public void testCorrelableFilter() {
IdmRoleDto role = getHelper().createRole();
role.setExternalId(getHelper().createName());
role.setCode(getHelper().createName());
role.setDescription(getHelper().createName());
IdmRoleDto roleFull = roleService.save(role);
ArrayList<Field> fields = Lists.newArrayList(IdmRole_.class.getFields());
IdmRoleFilter filter = new IdmRoleFilter();
fields.forEach(field -> {
if (Modifier.isStatic(field.getModifiers())) {
// static filter properties cannot be used by simple correlable filter
} else {
filter.setProperty(field.getName());
try {
Object value = EntityUtils.getEntityValue(roleFull, field.getName());
if (value == null || !(value instanceof String)) {
return;
}
filter.setValue(value.toString());
List<IdmRoleDto> identities = roleService.find(filter, null).getContent();
Assert.assertTrue(identities.contains(roleFull));
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | IntrospectionException e) {
e.printStackTrace();
}
}
});
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleServiceIntegrationTest method guaranteeRoleFilterTest.
@Test
public void guaranteeRoleFilterTest() {
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityOther = getHelper().createIdentity((GuardedString) null);
IdmRoleDto role = getHelper().createRole();
IdmRoleDto guaranteeRole = getHelper().createRole();
IdmRoleGuaranteeRoleDto roleGuaranteeRole = new IdmRoleGuaranteeRoleDto();
roleGuaranteeRole.setRole(role.getId());
roleGuaranteeRole.setGuaranteeRole(guaranteeRole.getId());
roleGuaranteeRoleService.save(roleGuaranteeRole);
getHelper().createIdentityRole(identity, guaranteeRole);
//
IdmRoleFilter filter = new IdmRoleFilter();
filter.setGuaranteeId(identity.getId());
Page<IdmRoleDto> result = roleService.find(filter, null);
Assert.assertEquals("Wrong guarantee", 1, result.getTotalElements());
Assert.assertEquals("Wrong guarantee id", role.getId(), result.getContent().get(0).getId());
//
filter.setGuaranteeId(identityOther.getId());
result = roleService.find(filter, null);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method doStartSyncA_MissingEntity.
@Test
public void doStartSyncA_MissingEntity() {
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));
//
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.CREATE_ENTITY == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(createEntityActionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(5, items.size());
IdmRoleFilter roleFilter = new IdmRoleFilter();
roleFilter.setProperty(IdmRole_.code.getName());
roleFilter.setValue("1");
Assert.assertEquals(1, roleService.find(roleFilter, null).getTotalElements());
roleFilter.setValue("2");
Assert.assertEquals(1, roleService.find(roleFilter, null).getTotalElements());
roleFilter.setValue("3");
Assert.assertEquals(1, roleService.find(roleFilter, null).getTotalElements());
roleFilter.setValue("4");
Assert.assertEquals(1, roleService.find(roleFilter, null).getTotalElements());
roleFilter.setValue("5");
Assert.assertEquals(1, roleService.find(roleFilter, null).getTotalElements());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method provisioningD_UpdateAccount.
@Test
public void provisioningD_UpdateAccount() {
// 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);
// Check state before provisioning
TestRoleResource ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
Assert.assertNotNull(ten);
Assert.assertEquals(2, ten.getPriority());
roleTen.setPriority(10);
// Save IDM changed node (must invoke provisioning)
roleService.save(roleTen);
// Check state after provisioning
ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
Assert.assertNotNull(ten);
Assert.assertEquals(10, ten.getPriority());
// Delete role mapping
systemMappingService.delete(mapping);
}
Aggregations