Search in sources :

Example 61 with IdmTreeNodeDto

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

the class InitTestData method init.

protected void init() {
    // we are reusing demo data in tests as well
    initDemoData.init();
    // 
    securityService.setSystemAuthentication();
    // 
    try {
        IdmRoleDto superAdminRole = this.roleService.getByCode(InitApplicationData.ADMIN_ROLE);
        IdmTreeNodeDto rootOrganization = treeNodeService.findRoots((UUID) null, new PageRequest(0, 1)).getContent().get(0);
        // 
        if (!configurationService.getBooleanValue(PARAMETER_TEST_DATA_CREATED, false)) {
            log.info("Creating test data ...");
            // 
            IdmRoleDto role1 = new IdmRoleDto();
            role1.setName(TEST_USER_ROLE);
            role1 = this.roleService.save(role1);
            log.info(MessageFormat.format("Test role created [id: {0}]", role1.getId()));
            // 
            IdmRoleDto role2 = new IdmRoleDto();
            role2.setName(TEST_CUSTOM_ROLE);
            List<IdmRoleCompositionDto> subRoles = new ArrayList<>();
            subRoles.add(new IdmRoleCompositionDto(role2.getId(), superAdminRole.getId()));
            role2.setSubRoles(subRoles);
            role2 = this.roleService.save(role2);
            log.info(MessageFormat.format("Test role created [id: {0}]", role2.getId()));
            // 
            // Users for JUnit testing
            IdmIdentityDto testUser1 = new IdmIdentityDto();
            testUser1.setUsername(TEST_USER_1);
            testUser1.setPassword(new GuardedString("heslo"));
            testUser1.setFirstName("Test");
            testUser1.setLastName("First User");
            testUser1.setEmail("test1@bscsolutions.eu");
            testUser1 = this.identityService.save(testUser1);
            log.info(MessageFormat.format("Identity created [id: {0}]", testUser1.getId()));
            IdmIdentityDto testUser2 = new IdmIdentityDto();
            testUser2.setUsername(TEST_USER_2);
            testUser2.setPassword(new GuardedString("heslo"));
            testUser2.setFirstName("Test");
            testUser2.setLastName("Second User");
            testUser2.setEmail("test2@bscsolutions.eu");
            testUser2 = this.identityService.save(testUser2);
            log.info(MessageFormat.format("Identity created [id: {0}]", testUser2.getId()));
            IdmTreeTypeDto type = this.treeTypeService.get(rootOrganization.getTreeType());
            IdmTreeNodeDto organization = new IdmTreeNodeDto();
            organization.setCode("test");
            organization.setName("Organization Test");
            organization.setCreator("ja");
            organization.setParent(rootOrganization.getId());
            organization.setTreeType(type.getId());
            organization = this.treeNodeService.save(organization);
            IdmIdentityContractDto identityWorkPosition2 = new IdmIdentityContractDto();
            identityWorkPosition2.setIdentity(testUser1.getId());
            identityWorkPosition2.setWorkPosition(organization.getId());
            identityWorkPosition2 = identityContractService.save(identityWorkPosition2);
            IdmContractGuaranteeDto contractGuarantee = new IdmContractGuaranteeDto();
            contractGuarantee.setIdentityContract(identityWorkPosition2.getId());
            contractGuarantee.setGuarantee(testUser2.getId());
            contractGuaranteeService.save(contractGuarantee);
            // 
            log.info("Test data was created.");
            // 
            configurationService.setBooleanValue(PARAMETER_TEST_DATA_CREATED, true);
        }
    // 
    } finally {
        SecurityContextHolder.clearContext();
    }
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) PageRequest(org.springframework.data.domain.PageRequest) IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto) ArrayList(java.util.ArrayList) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)

Example 62 with IdmTreeNodeDto

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

the class DefaultFormServiceItegrationTest method testFindTreeNodesByNullAttributeValue.

@Test
public void testFindTreeNodesByNullAttributeValue() {
    IdmTreeNodeDto owner = helper.createTreeNode();
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmTreeNode.class);
    IdmFormAttributeDto attribute = formDefinition.getFormAttributes().get(0);
    // 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.getCode(), 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) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 63 with IdmTreeNodeDto

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

the class IdentityFilterTest method testIncludeGuaranteesFilter.

@Test
public void testIncludeGuaranteesFilter() {
    IdmIdentityDto person = getIdmIdentity("aThisIsTestName009", "ThisIsTestName009", "ThisIsTestName009@gemail.eu", "000000009", false);
    IdmIdentityDto manager2 = getIdmIdentity("manager009", "ThisIsTestName009", "ThisIsTestName009@gemail.eu", "000000009", false);
    IdmIdentityDto manager = getIdmIdentity("ThisIsTestName010", "ThisIsTestName010", "ThisIsTestName010@gemail.eu", "000000010", false);
    IdmTreeTypeDto type1 = helper.createTreeType("ThisIsTestType0004");
    IdmTreeNodeDto node1 = helper.createTreeNode(type1, "ThisIsTestNode0004", null);
    IdmTreeNodeDto node2 = helper.createTreeNode(type1, "NextThisIsTestNode0004", node1);
    IdmIdentityContractDto contract = helper.createIdentityContact(person, node2);
    helper.createContractGuarantee(contract.getId(), manager2.getId());
    helper.createIdentityContact(manager, node1);
    IdmIdentityFilter filter = new IdmIdentityFilter();
    filter.setManagersFor(person.getId());
    filter.setIncludeGuarantees(true);
    Page<IdmIdentityDto> result = identityService.find(filter, null);
    assertEquals("Wrong Managers2For", 2, result.getTotalElements());
    filter.setIncludeGuarantees(false);
    result = identityService.find(filter, null);
    assertEquals("Wrong Managers2For test 2", 1, result.getTotalElements());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 64 with IdmTreeNodeDto

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

the class IdentityFilterTest method testSameButDifferentTreeTypeFilter.

@Test
public void testSameButDifferentTreeTypeFilter() {
    IdmIdentityDto person1 = getIdmIdentity("thistn01", "thistn01", "thistn02@a.eu", "000010001", false);
    getIdmIdentity("thistn01", "thistn01", "thistn02@a.eu", "000010001", false);
    IdmTreeTypeDto type1 = helper.createTreeType("typeName001");
    IdmTreeTypeDto type2 = helper.createTreeType("typeName002");
    IdmTreeNodeDto node1 = helper.createTreeNode(type1, "nodeName001", null);
    helper.createTreeNode(type2, "nodeName002", null);
    helper.createIdentityContact(person1, node1);
    helper.createIdentityContact(person1, node1);
    IdmIdentityFilter filter = new IdmIdentityFilter();
    filter.setFirstName(person1.getFirstName());
    Page<IdmIdentityDto> result = identityService.find(filter, null);
    assertEquals("Wrong sameButDiff filter", 2, result.getTotalElements());
    filter.setTreeType(type1.getId());
    result = identityService.find(filter, null);
    assertEquals("Wrong sameButDiff filter 2", 1, result.getTotalElements());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 65 with IdmTreeNodeDto

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

the class IdentityFilterTest method testTreeTypeFilter.

@Test
public void testTreeTypeFilter() {
    IdmIdentityDto person = getIdmIdentity("ThisIsTestName007", "ThisIsTestName007", "ThisIsTestName007@gemail.eu", "000000007", false);
    IdmTreeTypeDto type = helper.createTreeType("ThisIsTestType002");
    IdmTreeNodeDto node = helper.createTreeNode(type, "ThisIsTestNode002", null);
    UUID typeUuid = type.getId();
    helper.createIdentityContact(person, node);
    IdmIdentityFilter filter = new IdmIdentityFilter();
    filter.setTreeType(typeUuid);
    Page<IdmIdentityDto> result = identityService.find(filter, null);
    assertEquals("Wrong TreeType", 1, result.getTotalElements());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

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