use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter in project CzechIdMng by bcvsolutions.
the class HrEndContractProcess method getItemsToProcess.
/**
* {@inheritDoc}
*
* Find all identity contracts, that are both valid and enabled.
*/
@Override
public Page<IdmIdentityContractDto> getItemsToProcess(Pageable pageable) {
IdmIdentityContractFilter filter = new IdmIdentityContractFilter();
filter.setValid(Boolean.FALSE);
return identityContractService.find(filter, pageable);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter in project CzechIdMng by bcvsolutions.
the class IdmIdentityContractController method toFilter.
@Override
protected IdmIdentityContractFilter toFilter(MultiValueMap<String, Object> parameters) {
IdmIdentityContractFilter filter = new IdmIdentityContractFilter(parameters);
filter.setText(getParameterConverter().toString(parameters, "text"));
filter.setIdentity(getParameterConverter().toEntityUuid(parameters, "identity", IdmIdentity.class));
filter.setValid(getParameterConverter().toBoolean(parameters, "valid"));
filter.setExterne(getParameterConverter().toBoolean(parameters, "externe"));
filter.setDisabled(getParameterConverter().toBoolean(parameters, "disabled"));
filter.setMain(getParameterConverter().toBoolean(parameters, "main"));
filter.setValidNowOrInFuture(getParameterConverter().toBoolean(parameters, "validNowOrInFuture"));
// TODO: localdate converters
return filter;
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter in project CzechIdMng by bcvsolutions.
the class IdentityContractSyncTest method defaultLeaderTest.
@Test
public void defaultLeaderTest() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
Assert.assertTrue(config instanceof SysSyncContractConfigDto);
helper.createIdentity(CONTRACT_OWNER_ONE);
helper.createIdentity(CONTRACT_OWNER_TWO);
helper.createIdentity(CONTRACT_LEADER_ONE);
IdmIdentityDto defaultLeader = helper.createIdentity(CONTRACT_LEADER_TWO);
// Set default leader to sync configuration
SysSyncContractConfigDto configContract = (SysSyncContractConfigDto) config;
configContract.setDefaultLeader(defaultLeader.getId());
config = syncConfigService.save(configContract);
IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
contractFilter.setProperty(IdmIdentityContract_.position.getName());
contractFilter.setValue("1");
Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
contractFilter.setValue("2");
Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
synchornizationService.setSynchronizationConfigId(config.getId());
synchornizationService.process();
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
contractFilter.setValue("1");
List<IdmIdentityContractDto> contractsOne = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsOne.size());
IdmContractGuaranteeFilter guaranteeFilter = new IdmContractGuaranteeFilter();
guaranteeFilter.setIdentityContractId(contractsOne.get(0).getId());
List<IdmContractGuaranteeDto> gurantees = guaranteeService.find(guaranteeFilter, null).getContent();
Assert.assertEquals(1, gurantees.size());
IdmIdentityDto guarantee = DtoUtils.getEmbedded(gurantees.get(0), IdmContractGuarantee_.guarantee, IdmIdentityDto.class);
// Direct leader from resource
Assert.assertEquals(CONTRACT_LEADER_ONE, guarantee.getUsername());
contractFilter.setValue("2");
List<IdmIdentityContractDto> contractsTwo = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsTwo.size());
guaranteeFilter.setIdentityContractId(contractsTwo.get(0).getId());
gurantees = guaranteeService.find(guaranteeFilter, null).getContent();
Assert.assertEquals(1, gurantees.size());
guarantee = DtoUtils.getEmbedded(gurantees.get(0), IdmContractGuarantee_.guarantee, IdmIdentityDto.class);
// Default leader
Assert.assertEquals(CONTRACT_LEADER_TWO, guarantee.getUsername());
contractFilter.setValue("3");
List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsThree.size());
guaranteeFilter.setIdentityContractId(contractsThree.get(0).getId());
gurantees = guaranteeService.find(guaranteeFilter, null).getContent();
Assert.assertEquals(1, gurantees.size());
guarantee = DtoUtils.getEmbedded(gurantees.get(0), IdmContractGuarantee_.guarantee, IdmIdentityDto.class);
// Default leader
Assert.assertEquals(CONTRACT_LEADER_TWO, guarantee.getUsername());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter in project CzechIdMng by bcvsolutions.
the class IdentityContractSyncTest method checkContractDisableTest.
@Test
public void checkContractDisableTest() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
Assert.assertTrue(config instanceof SysSyncContractConfigDto);
helper.createIdentity(CONTRACT_OWNER_ONE);
helper.createIdentity(CONTRACT_OWNER_TWO);
helper.createIdentity(CONTRACT_LEADER_ONE);
IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
contractFilter.setProperty(IdmIdentityContract_.position.getName());
contractFilter.setValue("1");
Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
contractFilter.setValue("2");
Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
// Change resources (set state on disable) .. must be call in
// transaction
this.getBean().initContractCheckDisableTest();
synchornizationService.setSynchronizationConfigId(config.getId());
synchornizationService.process();
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
contractFilter.setValue("1");
List<IdmIdentityContractDto> contractsOne = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsOne.size());
Assert.assertEquals(ContractState.DISABLED, contractsOne.get(0).getState());
contractFilter.setValue("2");
List<IdmIdentityContractDto> contractsTwo = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsTwo.size());
Assert.assertEquals(null, contractsTwo.get(0).getState());
contractFilter.setValue("3");
List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsThree.size());
Assert.assertEquals(ContractState.DISABLED, contractsThree.get(0).getState());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter in project CzechIdMng by bcvsolutions.
the class IdentityContractSyncTest method checkContractExcludeTest.
@Test
public void checkContractExcludeTest() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
Assert.assertTrue(config instanceof SysSyncContractConfigDto);
helper.createIdentity(CONTRACT_OWNER_ONE);
helper.createIdentity(CONTRACT_OWNER_TWO);
helper.createIdentity(CONTRACT_LEADER_ONE);
IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
contractFilter.setProperty(IdmIdentityContract_.position.getName());
contractFilter.setValue("1");
Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
contractFilter.setValue("2");
Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
// Change resources (set state on exclude) .. must be call in
// transaction
this.getBean().initContractCheckExcludeTest();
synchornizationService.setSynchronizationConfigId(config.getId());
synchornizationService.process();
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
contractFilter.setValue("1");
Assert.assertEquals(1, contractService.find(contractFilter, null).getTotalElements());
contractFilter.setValue("2");
List<IdmIdentityContractDto> contractsTwo = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsTwo.size());
Assert.assertEquals(null, contractsTwo.get(0).getState());
contractFilter.setValue("3");
List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsThree.size());
Assert.assertEquals(ContractState.EXCLUDED, contractsThree.get(0).getState());
// Delete log
syncLogService.delete(log);
}
Aggregations