use of eu.bcvsolutions.idm.acc.entity.TestContractSliceResource in project CzechIdMng by bcvsolutions.
the class ContractSliceSyncTest method createContract.
private TestContractSliceResource createContract(String code, String owner, String leader, String main, String workposition, String state, String disabled, LocalDate validFromContract, LocalDate validTillContract, LocalDate validFromSlice, String contractCode) {
TestContractSliceResource contract = new TestContractSliceResource();
contract.setId(code);
contract.setName(code);
contract.setOwner(owner);
contract.setState(state);
contract.setDisabled(disabled);
contract.setLeader(leader);
contract.setMain(main);
contract.setWorkposition(workposition);
contract.setDescription(code);
contract.setValidFrom(validFromContract);
contract.setValidTill(validTillContract);
contract.setValidFromSlice(validFromSlice);
contract.setContractCode(contractCode);
return contract;
}
use of eu.bcvsolutions.idm.acc.entity.TestContractSliceResource in project CzechIdMng by bcvsolutions.
the class ContractSliceSyncTest method createTestDataStepTwo.
@Transactional
public void createTestDataStepTwo(String owner, String treeNodeCode) {
TestContractSliceResource sliceOne = entityManager.find(TestContractSliceResource.class, "1");
sliceOne.setValidTill(LocalDate.now().minusDays(7));
entityManager.persist(this.createContract("2", owner, null, "true", treeNodeCode, null, null, LocalDate.now().minusDays(4), null, LocalDate.now().minusDays(5), "ONE"));
}
use of eu.bcvsolutions.idm.acc.entity.TestContractSliceResource in project CzechIdMng by bcvsolutions.
the class ContractSliceSyncTest method deleteSlice.
@Transactional
public void deleteSlice(String id) {
TestContractSliceResource slice = entityManager.find(TestContractSliceResource.class, id);
entityManager.remove(slice);
}
use of eu.bcvsolutions.idm.acc.entity.TestContractSliceResource in project CzechIdMng by bcvsolutions.
the class ContractSliceSyncTest method updateAccountTest.
@Test
public void updateAccountTest() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
Assert.assertTrue(config instanceof SysSyncContractConfigDto);
config = syncConfigService.save(config);
helper.createIdentity(CONTRACT_OWNER_ONE);
helper.createIdentity(CONTRACT_OWNER_TWO);
helper.createIdentity(CONTRACT_LEADER_ONE);
IdmContractSliceFilter contractFilter = new IdmContractSliceFilter();
contractFilter.setProperty(IdmIdentityContract_.position.getName());
contractFilter.setValue("1");
Assert.assertEquals(0, contractSliceService.find(contractFilter, null).getTotalElements());
contractFilter.setValue("2");
Assert.assertEquals(0, contractSliceService.find(contractFilter, null).getTotalElements());
helper.startSynchronization(config);
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 4);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
contractFilter.setValue("1");
List<IdmContractSliceDto> contractSlices = contractSliceService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractSlices.size());
// Find the account for this contract slice
IdmContractSliceDto slice = contractSlices.get(0);
AccContractSliceAccountFilter contractAccountFilter = new AccContractSliceAccountFilter();
contractAccountFilter.setSliceId(slice.getId());
contractAccountFilter.setSystemId(system.getId());
List<AccContractSliceAccountDto> contractAccounts = contractSliceAccountService.find(contractAccountFilter, null).getContent();
Assert.assertEquals(1, contractAccounts.size());
AccContractSliceAccountDto contractAccount = contractAccounts.get(0);
AccAccountDto account = accountService.get(contractAccount.getAccount());
Assert.assertNotNull(account);
// Delete log
syncLogService.delete(log);
TestContractSliceResource accountOnTargetSystem = this.getBean().findSliceOnTargetSystem("1");
Assert.assertNull(accountOnTargetSystem.getState());
// Set slice to disabled
slice.setState(ContractState.DISABLED);
// Change settings of sync and run
config.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ACCOUNT);
config.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
config.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
config.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
config = syncConfigService.save(config);
helper.startSynchronization(config);
log = checkSyncLog(config, SynchronizationActionType.UPDATE_ACCOUNT, 4);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
// Sync of slice does not supports provisioning now (account was not changed)!
accountOnTargetSystem = this.getBean().findSliceOnTargetSystem("1");
Assert.assertEquals(null, accountOnTargetSystem.getState());
// Delete log
syncLogService.delete(log);
}
Aggregations