Search in sources :

Example 96 with IdmIdentityContractDto

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

the class DefaultIdmIdentityContractServiceIntegrationTest method testSetStateByDateValidInFuture.

@Test
public void testSetStateByDateValidInFuture() {
    IdmIdentityContractDto contract = helper.createIdentityContact(helper.createIdentity(), null, new LocalDate().plusDays(1), null);
    // 
    Assert.assertNull(contract.getState());
    Assert.assertFalse(((IdmIdentityContract) lookupService.lookupEntity(IdmIdentityContractDto.class, contract.getId())).isDisabled());
}
Also used : 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 97 with IdmIdentityContractDto

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

the class DefaultIdmIdentityContractServiceIntegrationTest method testFindAllValidContracts.

@Test
public void testFindAllValidContracts() {
    IdmIdentityDto identity = helper.createIdentity();
    // 
    List<IdmIdentityContractDto> contracts = service.findAllValidForDate(identity.getId(), LocalDate.now(), false);
    Assert.assertEquals(1, contracts.size());
    // 
    IdmIdentityContractDto contract = helper.getPrimeContract(identity.getId());
    contract.setState(ContractState.DISABLED);
    contract = service.save(contract);
    // 
    contracts = service.findAllValidForDate(identity.getId(), LocalDate.now(), false);
    Assert.assertEquals(0, contracts.size());
    // 
    // invalid
    helper.createIdentityContact(identity, null, LocalDate.now().plusDays(1), null);
    contracts = service.findAllValidForDate(identity.getId(), LocalDate.now(), false);
    Assert.assertEquals(0, contracts.size());
    contracts = service.findAllValidForDate(identity.getId(), LocalDate.now().plusDays(1), false);
    Assert.assertEquals(1, contracts.size());
    // 
    // externe
    contracts = service.findAllValidForDate(identity.getId(), LocalDate.now(), true);
    Assert.assertEquals(0, contracts.size());
    contract.setExterne(true);
    contract.setState(ContractState.EXCLUDED);
    contract = service.save(contract);
    contracts = service.findAllValidForDate(identity.getId(), LocalDate.now(), true);
    Assert.assertEquals(1, contracts.size());
}
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 98 with IdmIdentityContractDto

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

the class DefaultIdmIdentityContractServiceIntegrationTest method testEnableIdentityAfterIncludeContract.

@Test
public void testEnableIdentityAfterIncludeContract() {
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityContractDto contract = helper.getPrimeContract(identity.getId());
    contract.setState(ContractState.EXCLUDED);
    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 99 with IdmIdentityContractDto

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

the class DefaultIdmIdentityContractServiceIntegrationTest method testAssingRoleForContractValidInTheFuture.

@Test
public void testAssingRoleForContractValidInTheFuture() {
    IdmIdentityDto identity = helper.createIdentity();
    // 
    IdmIdentityContractDto contractD = new IdmIdentityContractDto();
    contractD.setIdentity(identity.getId());
    contractD.setWorkPosition(nodeD.getId());
    contractD.setValidFrom(new LocalDate().plusDays(1));
    contractD = service.save(contractD);
    // 
    // create new automatic role
    automaticRoleD = new IdmRoleTreeNodeDto();
    automaticRoleD.setRecursionType(RecursionType.NO);
    automaticRoleD.setRole(roleA.getId());
    automaticRoleD.setTreeNode(nodeD.getId());
    automaticRoleD = saveAutomaticRole(automaticRoleD, true);
    // 
    // check
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contractD.getId());
    assertEquals(1, identityRoles.size());
    assertEquals(automaticRoleD.getId(), identityRoles.get(0).getRoleTreeNode());
}
Also used : IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) 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 100 with IdmIdentityContractDto

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

the class DefaultIdmIdentityServiceIntegrationTest method testCreateDefaultContract.

/**
 * When identity is created, then default contract have to be created too.
 */
@Test
public void testCreateDefaultContract() {
    IdmIdentityDto identity = new IdmIdentityDto();
    String username = "contract_test_" + System.currentTimeMillis();
    identity.setUsername(username);
    // confidential storage
    identity.setPassword(new GuardedString("heslo"));
    identity.setFirstName("Test");
    identity.setLastName("Identity");
    identity = identityService.save(identity);
    // 
    List<IdmIdentityContractDto> contracts = identityContractService.findAllByIdentity(identity.getId());
    assertEquals(1, contracts.size());
    // 
    IdmIdentityContractDto defaultContract = identityContractService.prepareMainContract(identity.getId());
    assertEquals(defaultContract.getIdentity(), contracts.get(0).getIdentity());
    assertEquals(defaultContract.getPosition(), contracts.get(0).getPosition());
    assertEquals(defaultContract.getWorkPosition(), contracts.get(0).getWorkPosition());
}
Also used : GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) 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

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