Search in sources :

Example 11 with IdmTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.

the class DefaultTreeSynchronizationServiceTest method provisioningD_UpdateAccount.

@Test
public void provisioningD_UpdateAccount() {
    IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
    filter.setProperty(NODE_NAME);
    filter.setValue("P1");
    IdmTreeNodeDto nodeRoot = treeNodeService.find(filter, null).getContent().get(0);
    Assert.assertNotNull(nodeRoot);
    filter.setValue("P12");
    IdmTreeNodeDto nodeOne = treeNodeService.find(filter, null).getContent().get(0);
    Assert.assertNotNull(nodeOne);
    // Check state before provisioning
    TestTreeResource one = entityManager.find(TestTreeResource.class, "P12");
    Assert.assertNotNull(one);
    Assert.assertEquals("P12", one.getCode());
    nodeOne.setCode(CHANGED);
    // Save IDM changed node (must invoke provisioning)
    treeNodeService.save(nodeOne);
    // Check state before provisioning
    one = entityManager.find(TestTreeResource.class, "P12");
    Assert.assertNotNull(one);
    Assert.assertEquals(CHANGED, one.getCode());
}
Also used : TestTreeResource(eu.bcvsolutions.idm.acc.entity.TestTreeResource) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 12 with IdmTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.

the class DefaultTreeSynchronizationServiceTest method provisioningC_CreateAccounts_correct.

@Test
public void provisioningC_CreateAccounts_correct() {
    IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
    filter.setProperty(NODE_NAME);
    filter.setValue("P1");
    IdmTreeNodeDto nodeRoot = treeNodeService.find(filter, null).getContent().get(0);
    Assert.assertNotNull(nodeRoot);
    filter.setValue("P12");
    IdmTreeNodeDto nodeOne = treeNodeService.find(filter, null).getContent().get(0);
    Assert.assertNotNull(nodeOne);
    // Check state before provisioning
    TestTreeResource one = entityManager.find(TestTreeResource.class, "P12");
    Assert.assertNull(one);
    TestTreeResource root = entityManager.find(TestTreeResource.class, "P1");
    Assert.assertNull(root);
    // Save IDM node again (must invoke provisioning)
    // Root first
    treeNodeService.save(nodeRoot);
    // Node next
    treeNodeService.save(nodeOne);
    // Check state before provisioning
    root = entityManager.find(TestTreeResource.class, "P1");
    Assert.assertNotNull(root);
    one = entityManager.find(TestTreeResource.class, "P12");
    Assert.assertNotNull(one);
}
Also used : TestTreeResource(eu.bcvsolutions.idm.acc.entity.TestTreeResource) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 13 with IdmTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.

the class DefaultTreeSynchronizationServiceTest method doStartSyncB_MissingAccount_DeleteEntity.

@Test
public void doStartSyncB_MissingAccount_DeleteEntity() {
    SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
    configFilter.setName(SYNC_CONFIG_NAME);
    List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
    // Remove node code to changed
    this.getBean().removeOne();
    Assert.assertEquals(1, syncConfigs.size());
    AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
    Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
    // Set sync config
    syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
    syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
    syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
    syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.DELETE_ENTITY);
    syncConfigService.save(syncConfigCustom);
    // Check state before sync
    IdmTreeNodeFilter nodeFilter = new IdmTreeNodeFilter();
    nodeFilter.setProperty(NODE_NAME);
    nodeFilter.setValue("111");
    IdmTreeNodeDto treeNode = treeNodeService.find(nodeFilter, null).getContent().get(0);
    Assert.assertNotNull(treeNode.getCode());
    synchornizationService.setSynchronizationConfigId(syncConfigCustom.getId());
    synchornizationService.process();
    // 
    SysSyncLogFilter logFilter = new SysSyncLogFilter();
    logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
    List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
    Assert.assertEquals(1, logs.size());
    SysSyncLogDto log = logs.get(0);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
    actionLogFilter.setSynchronizationLogId(log.getId());
    List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
    Assert.assertEquals(3, actions.size());
    SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
        return SynchronizationActionType.DELETE_ENTITY == action.getSyncAction();
    }).findFirst().get();
    SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
    itemLogFilter.setSyncActionLogId(actionLog.getId());
    List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
    Assert.assertEquals(1, items.size());
    // Check state after sync
    treeNode = treeNodeService.get(treeNode.getId());
    Assert.assertNull(treeNode);
    // Delete log
    syncLogService.delete(log);
}
Also used : IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSyncItemLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter) SysSyncActionLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 14 with IdmTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.

the class IdentityContractSyncTest method defaultWorkPositionTest.

@Test
public void defaultWorkPositionTest() {
    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);
    helper.createIdentity(CONTRACT_LEADER_TWO);
    // Set default tree type to sync configuration
    IdmTreeTypeDto treeType = treeTypeService.getByCode(InitApplicationData.DEFAULT_TREE_TYPE);
    Assert.assertNotNull(treeType);
    SysSyncContractConfigDto configContract = (SysSyncContractConfigDto) config;
    configContract.setDefaultTreeType(treeType.getId());
    // Set default tree node to sync configuration
    IdmTreeNodeFilter nodeFilter = new IdmTreeNodeFilter();
    nodeFilter.setCode("one");
    nodeFilter.setTreeTypeId(treeType.getId());
    List<IdmTreeNodeDto> nodes = treeNodeService.find(nodeFilter, null).getContent();
    Assert.assertEquals(1, nodes.size());
    IdmTreeNodeDto defaultNode = nodes.get(0);
    configContract.setDefaultTreeNode(defaultNode.getId());
    config = syncConfigService.save(configContract);
    IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
    contractFilter.setProperty(IdmIdentityContract_.position.getName());
    // Start sync
    synchornizationService.setSynchronizationConfigId(config.getId());
    synchornizationService.process();
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    // Default work positions must be set
    contractFilter.setValue("1");
    List<IdmIdentityContractDto> contractsOne = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsOne.size());
    Assert.assertEquals(defaultNode.getId(), contractsOne.get(0).getWorkPosition());
    contractFilter.setValue("2");
    List<IdmIdentityContractDto> contractsTwo = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsTwo.size());
    Assert.assertEquals(defaultNode.getId(), contractsTwo.get(0).getWorkPosition());
    contractFilter.setValue("3");
    List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsThree.size());
    Assert.assertEquals(defaultNode.getId(), contractsThree.get(0).getWorkPosition());
    // Delete log
    syncLogService.delete(log);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 15 with IdmTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmIdentityContractService method prepareMainContract.

@Override
public IdmIdentityContractDto prepareMainContract(UUID identityId) {
    Assert.notNull(identityId);
    // 
    // set identity
    IdmIdentityContractDto contract = new IdmIdentityContractDto();
    contract.setIdentity(identityId);
    contract.setMain(true);
    // 
    // set default contract name
    // TODO: add boolean attribute
    contract.setPosition(DEFAULT_POSITION_NAME);
    // 
    // set working position
    IdmTreeNodeDto defaultTreeNode = treeConfiguration.getDefaultNode();
    if (defaultTreeNode != null) {
        contract.setWorkPosition(defaultTreeNode.getId());
    }
    return contract;
}
Also used : IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)

Aggregations

IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)79 Test (org.junit.Test)48 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)44 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)35 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)31 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)26 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)21 UUID (java.util.UUID)13 IdmTreeNodeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter)12 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)12 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)9 LocalDate (org.joda.time.LocalDate)9 IdmIdentityContractFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter)7 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)6 IdmRoleTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto)6 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)6 ApiOperation (io.swagger.annotations.ApiOperation)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)5