Search in sources :

Example 6 with AccContractSliceAccountFilter

use of eu.bcvsolutions.idm.acc.dto.filter.AccContractSliceAccountFilter in project CzechIdMng by bcvsolutions.

the class ContractSliceSyncTest method unlinkAccountTest.

@Test
public void unlinkAccountTest() {
    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);
    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);
    // Change settings of sync and run
    config.setLinkedAction(SynchronizationLinkedActionType.UNLINK);
    config.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
    config.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
    config.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
    config = syncConfigService.save(config);
    helper.startSynchronization(config);
    log = checkSyncLog(config, SynchronizationActionType.UNLINK, 4);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    // Find the account for this contract slice ... unlink operation was executed,
    // none relation can be found
    contractAccountFilter = new AccContractSliceAccountFilter();
    contractAccountFilter.setSliceId(slice.getId());
    contractAccountFilter.setSystemId(system.getId());
    contractAccounts = contractSliceAccountService.find(contractAccountFilter, null).getContent();
    Assert.assertEquals(0, contractAccounts.size());
    account = accountService.get(account.getId());
    Assert.assertNull(account);
    // Delete log
    syncLogService.delete(log);
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) 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)

Example 7 with AccContractSliceAccountFilter

use of eu.bcvsolutions.idm.acc.dto.filter.AccContractSliceAccountFilter 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)

Example 8 with AccContractSliceAccountFilter

use of eu.bcvsolutions.idm.acc.dto.filter.AccContractSliceAccountFilter in project CzechIdMng by bcvsolutions.

the class AccContractSliceAccountController method toFilter.

@Override
protected AccContractSliceAccountFilter toFilter(MultiValueMap<String, Object> parameters) {
    AccContractSliceAccountFilter filter = new AccContractSliceAccountFilter();
    filter.setAccountId(getParameterConverter().toUuid(parameters, "accountId"));
    filter.setSliceId(getParameterConverter().toUuid(parameters, "sliceId"));
    filter.setSystemId(getParameterConverter().toUuid(parameters, "systemId"));
    filter.setOwnership(getParameterConverter().toBoolean(parameters, "ownership"));
    return filter;
}
Also used : AccContractSliceAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccContractSliceAccountFilter)

Example 9 with AccContractSliceAccountFilter

use of eu.bcvsolutions.idm.acc.dto.filter.AccContractSliceAccountFilter in project CzechIdMng by bcvsolutions.

the class ContractSliceSynchronizationExecutor method doUnlink.

/**
 * Operation remove IdentityContractAccount relations and linked roles
 *
 * @param account
 * @param removeIdentityContractIdentityContract
 * @param log
 * @param logItem
 * @param actionLogs
 */
protected void doUnlink(AccAccountDto account, boolean removeIdentityContractIdentityContract, SysSyncLogDto log, SysSyncItemLogDto logItem, List<SysSyncActionLogDto> actionLogs) {
    EntityAccountFilter entityAccountFilter = new AccContractSliceAccountFilter();
    entityAccountFilter.setAccountId(account.getId());
    List<AccContractSliceAccountDto> entityAccounts = contractAccoutnService.find((AccContractSliceAccountFilter) entityAccountFilter, null).getContent();
    if (entityAccounts.isEmpty()) {
        addToItemLog(logItem, "Warning! - Contract-account relation was not found!");
        initSyncActionLog(SynchronizationActionType.UPDATE_ENTITY, OperationResultType.WARNING, logItem, log, actionLogs);
        return;
    }
    addToItemLog(logItem, MessageFormat.format("Contract-account relations to delete {0}", entityAccounts));
    entityAccounts.stream().forEach(entityAccount -> {
        // We will remove contract account, but without delete connected
        // account
        contractAccoutnService.delete(entityAccount, false);
        addToItemLog(logItem, MessageFormat.format("Contract-account relation deleted (without call delete provisioning) (contract id: {0}, contract-account id: {1})", entityAccount.getSlice(), entityAccount.getId()));
    });
    return;
}
Also used : EntityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.EntityAccountFilter) AccContractSliceAccountDto(eu.bcvsolutions.idm.acc.dto.AccContractSliceAccountDto) AccContractSliceAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccContractSliceAccountFilter)

Aggregations

AccContractSliceAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccContractSliceAccountFilter)9 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)6 AccContractSliceAccountDto (eu.bcvsolutions.idm.acc.dto.AccContractSliceAccountDto)6 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)4 SysSyncContractConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto)4 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)4 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)4 IdmContractSliceDto (eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto)4 IdmContractSliceFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter)4 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)4 Test (org.junit.Test)4 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)3 UUID (java.util.UUID)2 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)1 AccContractAccountDto (eu.bcvsolutions.idm.acc.dto.AccContractAccountDto)1 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)1 AccRoleAccountDto (eu.bcvsolutions.idm.acc.dto.AccRoleAccountDto)1 AccRoleCatalogueAccountDto (eu.bcvsolutions.idm.acc.dto.AccRoleCatalogueAccountDto)1 AccTreeAccountDto (eu.bcvsolutions.idm.acc.dto.AccTreeAccountDto)1 AccContractAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccContractAccountFilter)1