use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIncompatibleRoleFilter in project CzechIdMng by bcvsolutions.
the class IdmIncompatibleRoleControllerRestTest method testFindBySub.
@Test
public void testFindBySub() {
IdmRoleDto roleOne = getHelper().createRole();
IdmRoleDto roleTwo = getHelper().createRole();
IdmRoleDto roleThree = getHelper().createRole();
//
IdmIncompatibleRoleDto incompatibleRoleOne = getHelper().createIncompatibleRole(roleOne, roleTwo);
IdmIncompatibleRoleDto incompatibleRoleTwo = getHelper().createIncompatibleRole(roleThree, roleOne);
IdmIncompatibleRoleDto incompatibleRoleThree = getHelper().createIncompatibleRole(roleThree, roleTwo);
//
IdmIncompatibleRoleFilter filter = new IdmIncompatibleRoleFilter();
filter.setSubId(roleOne.getId());
List<IdmIncompatibleRoleDto> incompatibleRoles = find(filter);
Assert.assertEquals(1, incompatibleRoles.size());
Assert.assertEquals(incompatibleRoleTwo.getId(), incompatibleRoles.get(0).getId());
//
filter.setSubId(roleTwo.getId());
incompatibleRoles = find(filter);
Assert.assertEquals(2, incompatibleRoles.size());
Assert.assertTrue(incompatibleRoles.stream().anyMatch(ir -> ir.getId().equals(incompatibleRoleOne.getId())));
Assert.assertTrue(incompatibleRoles.stream().anyMatch(ir -> ir.getId().equals(incompatibleRoleThree.getId())));
//
filter.setSubId(roleThree.getId());
incompatibleRoles = find(filter);
Assert.assertTrue(incompatibleRoles.isEmpty());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIncompatibleRoleFilter in project CzechIdMng by bcvsolutions.
the class IdmIncompatibleRoleControllerRestTest method testFindBySuperior.
@Test
public void testFindBySuperior() {
IdmRoleDto roleOne = getHelper().createRole();
IdmRoleDto roleTwo = getHelper().createRole();
IdmRoleDto roleThree = getHelper().createRole();
//
IdmIncompatibleRoleDto incompatibleRoleOne = getHelper().createIncompatibleRole(roleOne, roleTwo);
IdmIncompatibleRoleDto incompatibleRoleTwo = getHelper().createIncompatibleRole(roleThree, roleOne);
IdmIncompatibleRoleDto incompatibleRoleThree = getHelper().createIncompatibleRole(roleThree, roleTwo);
//
IdmIncompatibleRoleFilter filter = new IdmIncompatibleRoleFilter();
filter.setSuperiorId(roleOne.getId());
List<IdmIncompatibleRoleDto> incompatibleRoles = find(filter);
Assert.assertEquals(1, incompatibleRoles.size());
Assert.assertEquals(incompatibleRoleOne.getId(), incompatibleRoles.get(0).getId());
//
filter.setSuperiorId(roleThree.getId());
incompatibleRoles = find(filter);
Assert.assertEquals(2, incompatibleRoles.size());
Assert.assertTrue(incompatibleRoles.stream().anyMatch(ir -> ir.getId().equals(incompatibleRoleTwo.getId())));
Assert.assertTrue(incompatibleRoles.stream().anyMatch(ir -> ir.getId().equals(incompatibleRoleThree.getId())));
//
filter.setSuperiorId(roleTwo.getId());
incompatibleRoles = find(filter);
Assert.assertTrue(incompatibleRoles.isEmpty());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIncompatibleRoleFilter in project CzechIdMng by bcvsolutions.
the class RoleExportBulkAction method exportIncompatibleRoles.
/**
* Export incompatible roles for given role.
*
* @param role
*/
private void exportIncompatibleRoles(IdmRoleDto role) {
IdmIncompatibleRoleFilter incompatibleFilter = new IdmIncompatibleRoleFilter();
incompatibleFilter.setRoleId(role.getId());
List<IdmIncompatibleRoleDto> incompatibles = incompatibleRoleService.find(incompatibleFilter, null).getContent();
if (incompatibles.isEmpty()) {
incompatibleRoleService.export(ExportManager.BLANK_UUID, this.getBatch());
}
incompatibles.forEach(incompatible -> {
incompatibleRoleService.export(incompatible.getId(), this.getBatch());
});
// Set parent fields -> set authoritative mode. Here are two parent fields!
Set<String> parents = new LinkedHashSet<>();
parents.add(IdmIncompatibleRole_.superior.getName());
parents.add(IdmIncompatibleRole_.sub.getName());
this.getExportManager().setAuthoritativeMode(parents, IdmIncompatibleRoleFilter.PARAMETER_ROLE_ID, IdmIncompatibleRoleDto.class, this.getBatch());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIncompatibleRoleFilter in project CzechIdMng by bcvsolutions.
the class RoleExportBulkActionIntegrationTest method findIncompatibilites.
private List<IdmIncompatibleRoleDto> findIncompatibilites(IdmRoleDto role) {
IdmIncompatibleRoleFilter filter = new IdmIncompatibleRoleFilter();
filter.setRoleId(role.getId());
return incompatibleRoleService.find(filter, null).getContent();
}
Aggregations