Search in sources :

Example 1 with IdmIncompatibleRoleFilter

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());
}
Also used : List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) Autowired(org.springframework.beans.factory.annotation.Autowired) IdmIncompatibleRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIncompatibleRoleFilter) Test(org.junit.Test) Assert(org.junit.Assert) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIncompatibleRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIncompatibleRoleFilter) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Example 2 with IdmIncompatibleRoleFilter

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());
}
Also used : List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) Autowired(org.springframework.beans.factory.annotation.Autowired) IdmIncompatibleRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIncompatibleRoleFilter) Test(org.junit.Test) Assert(org.junit.Assert) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIncompatibleRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIncompatibleRoleFilter) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Example 3 with IdmIncompatibleRoleFilter

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());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IdmIncompatibleRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIncompatibleRoleFilter) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto)

Example 4 with IdmIncompatibleRoleFilter

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();
}
Also used : IdmIncompatibleRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIncompatibleRoleFilter)

Aggregations

IdmIncompatibleRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIncompatibleRoleFilter)4 IdmIncompatibleRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto)3 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)2 AbstractReadWriteDtoController (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController)2 AbstractReadWriteDtoControllerRestTest (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)2 List (java.util.List)2 Assert (org.junit.Assert)2 Test (org.junit.Test)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 LinkedHashSet (java.util.LinkedHashSet)1