Search in sources :

Example 36 with IdmTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmAutomaticRoleRequestServiceIntegrationTest method testCreateTreeAutomaticRoleWithApproval.

@Test
public void testCreateTreeAutomaticRoleWithApproval() {
    IdmRoleDto role = prepareRole();
    IdmTreeNodeDto nodeOne = helper.createTreeNode();
    IdmIdentityDto guaranteeIdentity = helper.createIdentity();
    IdmRoleGuaranteeDto guarantee = new IdmRoleGuaranteeDto();
    guarantee.setRole(role.getId());
    guarantee.setGuarantee(guaranteeIdentity.getId());
    role.getGuarantees().add(guarantee);
    role = roleService.save(role);
    IdmRoleTreeNodeDto automaticRole = new IdmRoleTreeNodeDto();
    automaticRole.setRole(role.getId());
    automaticRole.setName(role.getName());
    automaticRole.setTreeNode(nodeOne.getId());
    // Create automatic role via manager
    try {
        automaticRole = automaticRoleManager.createAutomaticRoleByTree(automaticRole, false);
    } catch (AcceptedException ex) {
        // The request is in approval
        Assert.assertNotNull(ex.getIdentifier());
        UUID requestId = UUID.fromString(ex.getIdentifier());
        loginAsNoAdmin(guaranteeIdentity.getUsername());
        try {
            completeTasksFromUsers(guaranteeIdentity.getUsername(), "approve");
        } catch (ResultCodeException e) {
            fail("User has permission to approve task. Error message: " + e.getLocalizedMessage());
        } catch (Exception e) {
            fail("Some problem: " + e.getLocalizedMessage());
        }
        IdmAutomaticRoleRequestDto request = roleRequestService.get(requestId);
        Assert.assertEquals(RequestState.EXECUTED, request.getState());
        Assert.assertNotNull(request.getAutomaticRole());
        IdmRoleTreeNodeDto treeAutomaticRole = roleTreeNodeService.get(request.getAutomaticRole());
        Assert.assertNotNull(treeAutomaticRole);
        Assert.assertEquals(nodeOne.getId(), treeAutomaticRole.getTreeNode());
        Assert.assertEquals(role.getId(), treeAutomaticRole.getRole());
        return;
    }
    fail("Automatic role request have to be approving by gurantee!");
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto) IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmAutomaticRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleRequestDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) AcceptedException(eu.bcvsolutions.idm.core.api.exception.AcceptedException) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) RoleRequestException(eu.bcvsolutions.idm.core.api.exception.RoleRequestException) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AcceptedException(eu.bcvsolutions.idm.core.api.exception.AcceptedException) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Example 37 with IdmTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmIdentityContractServiceIntegrationTest method externeFilterTest.

@Test
public void externeFilterTest() {
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityDto identity2 = helper.createIdentity();
    IdmTreeNodeDto node = helper.createTreeNode();
    IdmTreeNodeDto node2 = helper.createTreeNode();
    IdmIdentityContractDto contract = helper.createIdentityContact(identity, node);
    IdmIdentityContractDto contract2 = helper.createIdentityContact(identity2, node2);
    contract.setExterne(true);
    service.save(contract);
    contract2.setExterne(false);
    service.save(contract2);
    IdmIdentityContractFilter filter = new IdmIdentityContractFilter();
    filter.setExterne(true);
    Page<IdmIdentityContractDto> result = service.find(filter, null);
    assertTrue(result.getContent().contains(contract));
    assertFalse(result.getContent().contains(contract2));
    filter.setExterne(false);
    result = service.find(filter, null);
    assertTrue(result.getContent().contains(contract2));
    assertFalse(result.getContent().contains(contract));
}
Also used : IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 38 with IdmTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmIdentityContractServiceIntegrationTest method datesValidFilterTest.

@Test
public void datesValidFilterTest() {
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityDto identity2 = helper.createIdentity();
    IdmIdentityDto identity3 = helper.createIdentity();
    IdmIdentityDto identity4 = helper.createIdentity();
    IdmTreeNodeDto node = helper.createTreeNode();
    IdmTreeNodeDto node2 = helper.createTreeNode();
    IdmTreeNodeDto node3 = helper.createTreeNode();
    IdmTreeNodeDto node4 = helper.createTreeNode();
    IdmIdentityContractDto contract = helper.createIdentityContact(identity, node, org.joda.time.LocalDate.now(), org.joda.time.LocalDate.parse("2021-06-05"));
    IdmIdentityContractDto contract2 = helper.createIdentityContact(identity2, node2, org.joda.time.LocalDate.now(), org.joda.time.LocalDate.parse("2020-05-05"));
    IdmIdentityContractDto contract3 = helper.createIdentityContact(identity3, node3, org.joda.time.LocalDate.now(), org.joda.time.LocalDate.parse("2016-05-05"));
    IdmIdentityContractDto contract4 = helper.createIdentityContact(identity4, node4, org.joda.time.LocalDate.parse("2018-05-05"), org.joda.time.LocalDate.parse("2025-05-05"));
    IdmIdentityContractFilter filter = new IdmIdentityContractFilter();
    filter.setValidFrom(contract.getValidFrom());
    Page<IdmIdentityContractDto> result = service.find(filter, null);
    assertTrue(result.getContent().contains(contract));
    filter.setValidFrom(null);
    filter.setValidTill(contract2.getValidTill());
    result = service.find(filter, null);
    assertTrue(result.getContent().contains(contract2));
    filter.setValidTill(null);
    filter.setValid(true);
    result = service.find(filter, null);
    assertTrue(result.getContent().contains(contract));
    assertTrue(result.getContent().contains(contract2));
    assertFalse(result.getContent().contains(contract3));
    filter.setValid(null);
    filter.setValidNowOrInFuture(true);
    result = service.find(filter, null);
    assertTrue(result.getContent().contains(contract4));
    filter.setValidNowOrInFuture(false);
    result = service.find(filter, null);
    assertTrue(result.getContent().contains(contract3));
}
Also used : IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 39 with IdmTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmIdentityContractServiceIntegrationTest method testReferentialIntegrityOnTreeNode.

@Test
public void testReferentialIntegrityOnTreeNode() {
    helper.setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, false);
    try {
        // prepare data
        IdmRoleDto role = helper.createRole();
        IdmTreeNodeDto treeNode = helper.createTreeNode();
        // automatic role
        IdmRoleTreeNodeDto roleTreeNode = helper.createRoleTreeNode(role, treeNode, false);
        // 
        assertNotNull(roleTreeNode.getId());
        assertEquals(roleTreeNode.getId(), roleTreeNodeService.get(roleTreeNode.getId()).getId());
        // 
        helper.deleteTreeNode(treeNode.getId());
        // 
        assertNull(roleTreeNodeService.get(roleTreeNode.getId()));
    } finally {
        helper.setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, true);
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 40 with IdmTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmIdentityContractServiceIntegrationTest method textFilterTest.

@Test
public void textFilterTest() {
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityDto identity2 = helper.createIdentity();
    IdmIdentityDto identity3 = helper.createIdentity();
    IdmIdentityDto identity4 = helper.createIdentity();
    IdmTreeNodeDto node = helper.createTreeNode();
    node.setName("Position105");
    treeNodeService.save(node);
    IdmTreeNodeDto node2 = helper.createTreeNode();
    node2.setName("Position006");
    treeNodeService.save(node2);
    IdmTreeNodeDto node3 = helper.createTreeNode();
    node3.setCode("Position007");
    treeNodeService.save(node3);
    IdmTreeNodeDto node4 = helper.createTreeNode();
    node4.setCode("Position108");
    treeNodeService.save(node4);
    IdmIdentityContractDto contract = helper.createIdentityContact(identity, node);
    IdmIdentityContractDto contract2 = helper.createIdentityContact(identity2, node2);
    IdmIdentityContractDto contract3 = helper.createIdentityContact(identity3, node3);
    IdmIdentityContractDto contract4 = helper.createIdentityContact(identity4, node4);
    contract.setPosition("Position001");
    contract = service.save(contract);
    contract2.setPosition("Position102");
    service.save(contract2);
    contract3.setPosition("Position103");
    service.save(contract3);
    contract4.setPosition("Position104");
    service.save(contract4);
    IdmIdentityContractFilter filter = new IdmIdentityContractFilter();
    filter.setText("Position00");
    Page<IdmIdentityContractDto> result = service.find(filter, null);
    assertEquals("Wrong Text", 3, result.getTotalElements());
    assertTrue(result.getContent().contains(contract));
    assertTrue(result.getContent().contains(contract2));
    assertTrue(result.getContent().contains(contract3));
}
Also used : IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)79 Test (org.junit.Test)48 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)44 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)35 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)31 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)26 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)21 UUID (java.util.UUID)13 IdmTreeNodeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter)12 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)12 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)9 LocalDate (org.joda.time.LocalDate)9 IdmIdentityContractFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter)7 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)6 IdmRoleTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto)6 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)6 ApiOperation (io.swagger.annotations.ApiOperation)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)5