Search in sources :

Example 91 with IdmIdentityContractDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto 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 92 with IdmIdentityContractDto

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

the class DefaultIdmIdentityContractServiceIntegrationTest method testChangeContractValidityWithAssignedRoles.

@Test
public void testChangeContractValidityWithAssignedRoles() {
    prepareAutomaticRoles();
    // 
    // prepare identity and contract
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityContractDto contract = new IdmIdentityContractDto();
    contract.setIdentity(identity.getId());
    contract.setValidFrom(new LocalDate().minusDays(1));
    contract.setValidTill(new LocalDate().plusMonths(1));
    contract.setWorkPosition(nodeD.getId());
    contract = service.save(contract);
    // 
    // test after create
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contract.getId());
    assertEquals(3, identityRoles.size());
    for (IdmIdentityRoleDto identityRole : identityRoles) {
        assertEquals(contract.getValidFrom(), identityRole.getValidFrom());
        assertEquals(contract.getValidTill(), identityRole.getValidTill());
    }
    ;
    // test after change
    contract.setValidFrom(new LocalDate().minusDays(2));
    contract.setValidTill(new LocalDate().plusMonths(4));
    contract = service.save(contract);
    identityRoles = identityRoleService.findAllByContract(contract.getId());
    assertEquals(3, identityRoles.size());
    for (IdmIdentityRoleDto identityRole : identityRoles) {
        assertEquals(contract.getValidFrom(), identityRole.getValidFrom());
        assertEquals(contract.getValidTill(), identityRole.getValidTill());
    }
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) LocalDate(org.joda.time.LocalDate) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 93 with IdmIdentityContractDto

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

the class DefaultIdmIdentityContractServiceIntegrationTest method testEnableIdentityAfterEnableContract.

@Test
public void testEnableIdentityAfterEnableContract() {
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityContractDto contract = helper.getPrimeContract(identity.getId());
    contract.setState(ContractState.DISABLED);
    contract = service.save(contract);
    // 
    identity = (IdmIdentityDto) lookupService.lookupDto(IdmIdentityDto.class, identity.getId());
    Assert.assertTrue(identity.isDisabled());
    // 
    contract.setState(null);
    contract = service.save(contract);
    // 
    identity = (IdmIdentityDto) lookupService.lookupDto(IdmIdentityDto.class, identity.getId());
    Assert.assertFalse(identity.isDisabled());
}
Also used : 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 94 with IdmIdentityContractDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto 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)

Example 95 with IdmIdentityContractDto

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

the class DefaultIdmIdentityContractServiceIntegrationTest method testCRUDContractWithAutomaticRoles.

@Test
public void testCRUDContractWithAutomaticRoles() {
    prepareAutomaticRoles();
    // 
    // prepare identity and contract
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityContractDto contract = service.getPrimeContract(identity.getId());
    contract.setIdentity(identity.getId());
    contract.setValidFrom(new LocalDate().minusDays(1));
    contract.setValidTill(new LocalDate().plusMonths(1));
    contract.setWorkPosition(nodeD.getId());
    contract.setMain(true);
    contract.setDescription("test-node-d");
    service.save(contract);
    // 
    contract = service.getPrimeContract(identity.getId());
    // 
    // test after create
    assertEquals(nodeD.getId(), contract.getWorkPosition());
    assertEquals("test-node-d", contract.getDescription());
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contract.getId());
    assertEquals(3, identityRoles.size());
    for (IdmIdentityRoleDto identityRole : identityRoles) {
        assertEquals(contract.getValidFrom(), identityRole.getValidFrom());
        assertEquals(contract.getValidTill(), identityRole.getValidTill());
        if (identityRole.getRoleTreeNode().equals(nodeA.getId())) {
            assertEquals(roleA, identityRole.getRole());
        }
        if (identityRole.getRoleTreeNode().equals(nodeD.getId())) {
            assertEquals(roleB, identityRole.getRole());
        }
        if (identityRole.getRoleTreeNode().equals(nodeF.getId())) {
            assertEquals(roleC, identityRole.getRole());
        }
    }
    identityRoles = identityRoleService.findAllByIdentity(identity.getId());
    assertEquals(3, identityRoles.size());
    // 
    // test after delete
    service.delete(contract);
    assertTrue(identityRoleService.findAllByIdentity(identity.getId()).isEmpty());
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) LocalDate(org.joda.time.LocalDate) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)220 Test (org.junit.Test)170 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)156 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)92 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)91 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)53 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)48 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)45 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)44 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)36 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)35 LocalDate (org.joda.time.LocalDate)34 ArrayList (java.util.ArrayList)31 List (java.util.List)29 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)28 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)24 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)24 Transactional (org.springframework.transaction.annotation.Transactional)24 UUID (java.util.UUID)19 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)18