Search in sources :

Example 96 with IdmTreeNodeDto

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

the class DefaultFormServiceIntegrationTest method testFindTreeNodesByNullTextAttributeValue.

@Test
public void testFindTreeNodesByNullTextAttributeValue() {
    IdmTreeNodeDto owner = getHelper().createTreeNode();
    // 
    IdmFormAttributeDto attribute = new IdmFormAttributeDto();
    attribute.setCode(getHelper().createName());
    attribute.setName(attribute.getCode());
    attribute.setPersistentType(PersistentType.TEXT);
    IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmTreeNode.class.getCanonicalName(), getHelper().createName(), Lists.newArrayList(attribute));
    attribute = formDefinitionOne.getMappedAttributeByCode(attribute.getCode());
    // save values
    formService.saveValues(owner.getId(), IdmTreeNode.class, attribute, Lists.newArrayList(FORM_VALUE_ONE));
    // 
    Page<? extends Identifiable> owners = formService.findOwners(IdmTreeNode.class, attribute, FORM_VALUE_ONE, null);
    // 
    assertEquals(1, owners.getTotalElements());
    assertEquals(owner.getId(), owners.getContent().get(0).getId());
    // 
    owners = formService.findOwners(IdmTreeNode.class, attribute, null, null);
    assertEquals(0, owners.getTotalElements());
}
Also used : IdmTreeNode(eu.bcvsolutions.idm.core.model.entity.IdmTreeNode) 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) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 97 with IdmTreeNodeDto

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

the class IdmContractPositionControllerRestTest method testFilterByWorkPosition.

@Test
public void testFilterByWorkPosition() {
    IdmIdentityDto identity = getHelper().createIdentity();
    IdmIdentityContractDto primeContract = getHelper().getPrimeContract(identity);
    // 
    IdmTreeNodeDto treeNodeOne = getHelper().createTreeNode();
    IdmContractPositionDto dtoOne = createDto(new IdmContractPositionDto(primeContract.getId(), treeNodeOne.getId()));
    // other
    createDto(new IdmContractPositionDto(primeContract.getId(), getHelper().createTreeNode().getId()));
    // 
    IdmContractPositionFilter filter = new IdmContractPositionFilter();
    filter.setWorkPosition(treeNodeOne.getId());
    // 
    List<IdmContractPositionDto> results = find(filter);
    // 
    Assert.assertEquals(1, results.size());
    Assert.assertEquals(dtoOne.getId(), results.get(0).getId());
}
Also used : IdmContractPositionDto(eu.bcvsolutions.idm.core.api.dto.IdmContractPositionDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmContractPositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractPositionFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Example 98 with IdmTreeNodeDto

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

the class TreeNodeAndTypeRestTest method testCreateRootNodeTwice.

@Test
public void testCreateRootNodeTwice() {
    IdmTreeTypeDto type = getHelper().createTreeType();
    IdmTreeNodeDto root = new IdmTreeNodeDto();
    root.setCode(getHelper().createName());
    root.setName(getHelper().createName());
    root.setTreeType(type.getId());
    // save first root
    Exception ex = null;
    try {
        treeNodeService.save(root);
    } catch (Exception e) {
        ex = e;
    }
    assertNull(ex);
    // save second root, same type
    Map<String, String> body = new HashMap<>();
    body.put("code", getHelper().createName());
    body.put("name", getHelper().createName());
    body.put("treeType", type.getId().toString());
    String jsonContent = toJson(body);
    ex = null;
    int status = 0;
    try {
        status = getMockMvc().perform(post(BaseDtoController.BASE_PATH + "/tree-nodes").with(authentication(getAdminAuthentication())).content(jsonContent).contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse().getStatus();
    } catch (Exception e) {
        ex = e;
    }
    assertNull(ex);
    assertEquals(201, status);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) HashMap(java.util.HashMap) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IdmTreeNodeControllerRestTest(eu.bcvsolutions.idm.core.rest.impl.IdmTreeNodeControllerRestTest) Test(org.junit.Test) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest)

Example 99 with IdmTreeNodeDto

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

the class ChangesOnSystemReportIntegrationTest method testProvisioningOperationReportWithChanges.

@Test
public void testProvisioningOperationReportWithChanges() throws IOException {
    IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
    IdmTreeNodeDto position = getHelper().createTreeNode();
    getHelper().createContract(identityTwo, position);
    SysSystemDto system = createSystemWithOperation();
    SysSystemMappingDto defaultMapping = getHelper().getDefaultMapping(system);
    IdmRoleDto role = getHelper().createRole();
    getHelper().createRoleSystem(role, system);
    getHelper().createIdentityRole(identityTwo, role);
    // 
    AccAccountFilter accountFilter = new AccAccountFilter();
    accountFilter.setIdentityId(identityTwo.getId());
    accountFilter.setSystemId(system.getId());
    accountFilter.setEntityType(SystemEntityType.IDENTITY);
    List<AccAccountDto> accounts = accountService.find(accountFilter, null).getContent();
    Assert.assertEquals(1, accounts.size());
    // 
    // change => readonly system
    system.setDisabledProvisioning(true);
    system.setReadonly(true);
    system = systemService.save(system);
    identityTwo.setLastName(getHelper().createName());
    identityTwo = identityService.save(identityTwo);
    system.setDisabledProvisioning(false);
    system.setReadonly(false);
    system = systemService.save(system);
    // 
    // prepare report filter
    RptReportDto report = new RptReportDto(UUID.randomUUID());
    report.setExecutorName(reportExecutor.getName());
    IdmFormDto filter = new IdmFormDto();
    IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
    IdmFormValueDto filterValue = new IdmFormValueDto(definition.getMappedAttributeByCode(ChangesOnSystemReportExecutor.PARAMETER_MAPPING_ATTRIBUTES));
    // TODO: create json java POJO representation
    filterValue.setStringValue("{ \"system\": \"" + system.getId() + "\", \"systemMapping\": \"" + defaultMapping.getId() + "\", \"mappingAttributes\": [ ] }");
    filter.getValues().add(filterValue);
    IdmFormValueDto filterIdentitites = new IdmFormValueDto(definition.getMappedAttributeByCode(ChangesOnSystemReportExecutor.PARAMETER_ONLY_IDENTITY));
    filterIdentitites.setUuidValue(identityOne.getId());
    filter.getValues().add(filterIdentitites);
    IdmFormValueDto filterTreeNode = new IdmFormValueDto(definition.getMappedAttributeByCode(ChangesOnSystemReportExecutor.PARAMETER_TREE_NODE));
    filterTreeNode.setUuidValue(position.getId());
    filter.getValues().add(filterTreeNode);
    filter.setFormDefinition(definition.getId());
    report.setFilter(filter);
    // 
    // generate report
    report = reportExecutor.generate(report);
    Assert.assertNotNull(report.getData());
    // 
    // test renderer
    Assert.assertNotNull(xlsxRenderer.render(report));
    // 
    attachmentManager.deleteAttachments(report);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 100 with IdmTreeNodeDto

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

the class IdentityRoleByIdentityDeduplicationExecutorTest method testExecuteReportOneContractMoreRolesWithValidity.

@Test
public void testExecuteReportOneContractMoreRolesWithValidity() throws JsonParseException, JsonMappingException, IOException {
    String roleCode = "test-" + System.currentTimeMillis();
    IdmTreeNodeDto treeNode = getHelper().createTreeNode();
    IdmIdentityDto identity = getHelper().createIdentity(new GuardedString());
    IdmIdentityContractDto contact = getHelper().createContract(identity, treeNode);
    IdmRoleDto role = getHelper().createRole(roleCode);
    getHelper().createIdentityRole(contact, role, LocalDate.now().minusDays(40), LocalDate.now().plusDays(40));
    getHelper().createIdentityRole(contact, role, LocalDate.now().minusDays(30), LocalDate.now().plusDays(30));
    getHelper().createIdentityRole(contact, role, LocalDate.now().minusDays(20), LocalDate.now().plusDays(20));
    getHelper().createIdentityRole(contact, role, LocalDate.now().minusDays(10), LocalDate.now().plusDays(10));
    RptReportDto report = new RptReportDto(UUID.randomUUID());
    report.setExecutorName(reportExecutor.getName());
    IdmFormDto filter = new IdmFormDto();
    IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
    IdmFormValueDto treeNodeParameter = new IdmFormValueDto(definition.getMappedAttributeByCode(IdentityRoleByIdentityDeduplicationExecutor.PARAMETER_TREE_NODE));
    treeNodeParameter.setValue(treeNode.getId());
    filter.getValues().add(treeNodeParameter);
    filter.setFormDefinition(definition.getId());
    report.setFilter(filter);
    report = reportExecutor.generate(report);
    Assert.assertNotNull(report.getData());
    List<RptIdentityRoleByRoleDeduplicationDto> reportItems = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<RptIdentityRoleByRoleDeduplicationDto>>() {
    });
    assertEquals(1, reportItems.size());
    RptIdentityRoleByRoleDeduplicationDto item = reportItems.get(0);
    List<RptIdentityRoleByRoleDeduplicationDuplicityDto> duplicities = item.getDuplicity();
    assertEquals(3, duplicities.size());
    for (RptIdentityRoleByRoleDeduplicationDuplicityDto duplicity : duplicities) {
        assertEquals(role.getId(), duplicity.getRole().getId());
        if (duplicity.getValidTill().isEqual(duplicity.getValidFrom())) {
            fail();
        }
        if (!duplicity.getValidTill().isBefore(LocalDate.now().plusDays(35))) {
            fail();
        }
        if (!duplicity.getValidFrom().isAfter(LocalDate.now().minusDays(35))) {
            fail();
        }
    }
    attachmentManager.deleteAttachments(report);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) RptIdentityRoleByRoleDeduplicationDuplicityDto(eu.bcvsolutions.idm.rpt.dto.RptIdentityRoleByRoleDeduplicationDuplicityDto) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) RptIdentityRoleByRoleDeduplicationDto(eu.bcvsolutions.idm.rpt.dto.RptIdentityRoleByRoleDeduplicationDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) List(java.util.List) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)231 Test (org.junit.Test)172 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)130 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)122 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)102 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)102 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)92 UUID (java.util.UUID)56 IdmRoleTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto)44 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)44 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)42 IdmTreeNodeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter)39 Transactional (org.springframework.transaction.annotation.Transactional)38 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)33 List (java.util.List)31 IdmIdentityContractFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter)27 LocalDate (java.time.LocalDate)26 IdmContractPositionDto (eu.bcvsolutions.idm.core.api.dto.IdmContractPositionDto)25 Autowired (org.springframework.beans.factory.annotation.Autowired)25 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)23