Search in sources :

Example 41 with IdmTreeNodeDto

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

the class AbstractWorkingPositionFilterIntegrationTest method createPosition.

private IdmTreeNodeDto createPosition(IdmTreeTypeDto type, IdmTreeNodeDto parent) {
    IdmTreeNodeDto node = helper.createTreeNode(type, parent);
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmTreeNode.class, FormService.DEFAULT_DEFINITION_CODE);
    IdmFormAttributeDto attr = formDefinition.getMappedAttributeByCode(EavCodeSubordinatesFilter.DEFAULT_FORM_ATTRIBUTE_CODE);
    if (attr == null) {
        attr = new IdmFormAttributeDto();
        attr.setName("Parent code");
        attr.setCode(EavCodeSubordinatesFilter.DEFAULT_FORM_ATTRIBUTE_CODE);
        attr.setFormDefinition(formDefinition.getId());
        attr.setPersistentType(PersistentType.TEXT);
        attr.setUnmodifiable(true);
        attr = formService.saveAttribute(attr);
    }
    // 
    formService.saveValues(node, attr, Lists.newArrayList(parent.getCode()));
    // 
    return node;
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)

Example 42 with IdmTreeNodeDto

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

the class AbstractWorkingPositionFilterIntegrationTest method prepareData.

/**
 * prepare identities, tree structures and contracts
 * suborinateOne has managerOne by tree structure - structureOne
 * suborinateOne has managerTwo by tree structure - structureTwo
 * suborinateOne has guaranteeThree by contractOne
 * suborinateOne has guaranteeFour by contractTwo
 * suborinateOne is manager for suborinateTwo
 */
protected void prepareData() {
    managerOne = helper.createIdentity();
    managerTwo = helper.createIdentity();
    invalidManager = helper.createIdentity();
    guaranteeThree = helper.createIdentity();
    guaranteeFour = helper.createIdentity();
    subordinateOne = helper.createIdentity();
    subordinateTwo = helper.createIdentity();
    subordinateThree = helper.createIdentity();
    // 
    structureOne = helper.createTreeType();
    IdmTreeNodeDto managerOnePosition = helper.createTreeNode(structureOne, null);
    helper.createIdentityContact(managerOne, managerOnePosition);
    helper.createIdentityContact(invalidManager, managerOnePosition, new LocalDate().plusDays(1), null);
    // 
    structureTwo = helper.createTreeType();
    IdmTreeNodeDto managerTwoPosition = helper.createTreeNode(structureTwo, null);
    helper.createIdentityContact(managerTwo, managerTwoPosition);
    // subordinate one
    IdmTreeNodeDto subordinateOnePositionOne = createPosition(structureOne, managerOnePosition);
    contractOne = helper.createIdentityContact(subordinateOne, subordinateOnePositionOne);
    helper.createContractGuarantee(contractOne.getId(), guaranteeThree.getId());
    IdmTreeNodeDto subordinateOnePositionTwo = createPosition(structureTwo, managerTwoPosition);
    contractTwo = helper.createIdentityContact(subordinateOne, subordinateOnePositionTwo);
    helper.createContractGuarantee(contractTwo.getId(), guaranteeFour.getId());
    // subordinate two
    IdmTreeNodeDto subordinateTwoPosition = createPosition(structureOne, subordinateOnePositionOne);
    IdmIdentityContractDto contractSubordinateTwo = helper.createIdentityContact(subordinateTwo, subordinateTwoPosition);
    helper.createContractGuarantee(contractSubordinateTwo.getId(), guaranteeFour.getId());
    // subordinate three
    helper.createContractGuarantee(helper.createIdentityContact(subordinateThree).getId(), managerOne.getId());
}
Also used : IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) LocalDate(org.joda.time.LocalDate) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)

Example 43 with IdmTreeNodeDto

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

the class DefaultTreeSynchronizationServiceTest method provisioningB_CreateAccounts_withException.

// Provisioning tree in incorrect order
@Test(expected = ProvisioningException.class)
public void provisioningB_CreateAccounts_withException() {
    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);
    // Create mapping for provisioning
    this.createProvisionigMapping();
    // Save IDM node (must invoke provisioning)
    // We didn't provisioning for root first ... expect throw exception
    treeNodeService.save(nodeOne);
}
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 44 with IdmTreeNodeDto

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

the class DefaultTreeSynchronizationServiceTest method doStartSyncB_Linked_doEntityUpdate.

@Test
public void doStartSyncB_Linked_doEntityUpdate() {
    SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
    configFilter.setName(SYNC_CONFIG_NAME);
    List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
    // Change node code to changed
    this.getBean().changeOne();
    Assert.assertEquals(1, syncConfigs.size());
    AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
    Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
    // Set sync config
    syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
    syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
    syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
    syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
    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.assertEquals("111", 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(1, actions.size());
    SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
        return SynchronizationActionType.UPDATE_ENTITY == action.getSyncAction();
    }).findFirst().get();
    SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
    itemLogFilter.setSyncActionLogId(actionLog.getId());
    List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
    Assert.assertEquals(6, items.size());
    // Check state after sync
    treeNode = treeNodeService.get(treeNode.getId());
    Assert.assertEquals(CHANGED, treeNode.getCode());
    // 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 45 with IdmTreeNodeDto

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

the class DefaultTreeSynchronizationServiceTest method provisioningE_DeleteAccount_IntegrityException.

@Test(expected = TreeNodeException.class)
public void provisioningE_DeleteAccount_IntegrityException() {
    IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
    filter.setProperty(NODE_NAME);
    filter.setValue("P1");
    IdmTreeNodeDto nodeRoot = treeNodeService.find(filter, null).getContent().get(0);
    Assert.assertNotNull(nodeRoot);
    // Delete IDM node (must invoke provisioning) .. We delete node with some children ... must throw integrity exception
    // Generally we counts with provisioning on every node ... include children (Recursively delete is not good idea!)
    treeNodeService.delete(nodeRoot);
}
Also used : 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)

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