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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations