Search in sources :

Example 1 with TestContractSliceResource

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;
}
Also used : TestContractSliceResource(eu.bcvsolutions.idm.acc.entity.TestContractSliceResource)

Example 2 with TestContractSliceResource

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"));
}
Also used : TestContractSliceResource(eu.bcvsolutions.idm.acc.entity.TestContractSliceResource) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with TestContractSliceResource

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);
}
Also used : TestContractSliceResource(eu.bcvsolutions.idm.acc.entity.TestContractSliceResource) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with TestContractSliceResource

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);
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) TestContractSliceResource(eu.bcvsolutions.idm.acc.entity.TestContractSliceResource) IdmContractSliceFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter) AccContractSliceAccountDto(eu.bcvsolutions.idm.acc.dto.AccContractSliceAccountDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) AccContractSliceAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccContractSliceAccountFilter) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

TestContractSliceResource (eu.bcvsolutions.idm.acc.entity.TestContractSliceResource)4 Transactional (org.springframework.transaction.annotation.Transactional)2 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)1 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)1 AccContractSliceAccountDto (eu.bcvsolutions.idm.acc.dto.AccContractSliceAccountDto)1 SysSyncContractConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto)1 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)1 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)1 AccContractSliceAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccContractSliceAccountFilter)1 IdmContractSliceDto (eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto)1 IdmContractSliceFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter)1 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)1 Test (org.junit.Test)1