use of eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceUnitTest method testPrimeContractWithDefaultTreeType.
@Test
public void testPrimeContractWithDefaultTreeType() {
List<IdmIdentityContract> contracts = new ArrayList<>();
IdmIdentityContract contractWithDefaultPosition = new IdmIdentityContract(UUID.randomUUID());
contractWithDefaultPosition.setMain(false);
IdmTreeNode defaultWorkPosition = new IdmTreeNode();
IdmTreeType defaultTreeType = new IdmTreeType(UUID.randomUUID());
defaultWorkPosition.setTreeType(defaultTreeType);
contractWithDefaultPosition.setWorkPosition(defaultWorkPosition);
//
IdmIdentityContract otherContract = new IdmIdentityContract(UUID.randomUUID());
otherContract.setMain(false);
IdmTreeNode workPosition = new IdmTreeNode();
workPosition.setTreeType(new IdmTreeType(UUID.randomUUID()));
otherContract.setWorkPosition(workPosition);
//
contracts.add(contractWithDefaultPosition);
contracts.add(otherContract);
//
when(repository.findAllByIdentity_Id(any(UUID.class), any())).thenReturn(contracts);
when(treeConfiguration.getDefaultType()).thenReturn(new IdmTreeTypeDto(defaultTreeType.getId()));
//
Assert.assertEquals(contractWithDefaultPosition.getId(), service.getPrimeContract(UUID.randomUUID()).getId());
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceUnitTest method testDisabledMainContract.
/**
* Invalid main contract has still higher priority
*/
@Test
public void testDisabledMainContract() {
List<IdmIdentityContract> contracts = new ArrayList<>();
IdmIdentityContract invalidContract = new IdmIdentityContract(UUID.randomUUID());
invalidContract.setMain(true);
invalidContract.setDisabled(true);
IdmIdentityContract otherContract = new IdmIdentityContract(UUID.randomUUID());
otherContract.setMain(false);
contracts.add(otherContract);
contracts.add(invalidContract);
//
when(repository.findAllByIdentity_Id(any(UUID.class), any())).thenReturn(contracts);
when(treeConfiguration.getDefaultType()).thenReturn(null);
//
Assert.assertEquals(invalidContract.getId(), service.getPrimeContract(UUID.randomUUID()).getId());
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceUnitTest method testSimplePrimeContract.
@Test
public void testSimplePrimeContract() {
List<IdmIdentityContract> contracts = new ArrayList<>();
IdmIdentityContract otherContract = new IdmIdentityContract(UUID.randomUUID());
otherContract.setMain(false);
IdmIdentityContract mainContract = new IdmIdentityContract(UUID.randomUUID());
mainContract.setMain(true);
contracts.add(otherContract);
contracts.add(mainContract);
//
when(repository.findAllByIdentity_Id(any(UUID.class), any())).thenReturn(contracts);
when(treeConfiguration.getDefaultType()).thenReturn(null);
//
Assert.assertEquals(mainContract.getId(), service.getPrimeContract(UUID.randomUUID()).getId());
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceUnitTest method testSimpleValidPrimeContract.
@Test
public void testSimpleValidPrimeContract() {
List<IdmIdentityContract> contracts = new ArrayList<>();
IdmIdentityContract invalidContract = new IdmIdentityContract(UUID.randomUUID());
invalidContract.setMain(true);
invalidContract.setValidFrom(new LocalDate().plusDays(1));
IdmIdentityContract mainContract = new IdmIdentityContract(UUID.randomUUID());
mainContract.setMain(true);
contracts.add(invalidContract);
contracts.add(mainContract);
//
when(repository.findAllByIdentity_Id(any(UUID.class), any())).thenReturn(contracts);
when(treeConfiguration.getDefaultType()).thenReturn(null);
//
Assert.assertEquals(mainContract.getId(), service.getPrimeContract(UUID.randomUUID()).getId());
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceUnitTest method testOtherMainContractByValidFrom.
@Test
public void testOtherMainContractByValidFrom() {
List<IdmIdentityContract> contracts = new ArrayList<>();
IdmIdentityContract oneContract = new IdmIdentityContract(UUID.randomUUID());
oneContract.setValidFrom(new LocalDate());
oneContract.setMain(false);
IdmIdentityContract twoContract = new IdmIdentityContract(UUID.randomUUID());
twoContract.setMain(false);
twoContract.setValidFrom(new LocalDate().plusDays(1));
contracts.add(twoContract);
contracts.add(oneContract);
//
when(repository.findAllByIdentity_Id(any(UUID.class), any())).thenReturn(contracts);
when(treeConfiguration.getDefaultType()).thenReturn(null);
//
Assert.assertEquals(oneContract.getId(), service.getPrimeContract(UUID.randomUUID()).getId());
}
Aggregations