Search in sources :

Example 56 with IdmTreeTypeDto

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

the class IdmTreeNodeControllerRestTest method testFindByRootsAndChildren.

@Test
public void testFindByRootsAndChildren() {
    IdmTreeTypeDto treeType = getHelper().createTreeType();
    IdmTreeNodeDto nodeOne = getHelper().createTreeNode(treeType, null);
    IdmTreeNodeDto nodeTwo = getHelper().createTreeNode(treeType, nodeOne);
    // 
    // root
    IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
    filter.setTreeTypeId(treeType.getId());
    filter.setRoots(Boolean.TRUE);
    List<IdmTreeNodeDto> results = find(filter);
    Assert.assertEquals(1, results.size());
    Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(nodeOne.getId())));
    // is root - false
    filter.setRoots(Boolean.FALSE);
    results = find(filter);
    Assert.assertEquals(1, results.size());
    Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(nodeTwo.getId())));
    // 
    // children
    filter.setRoots(null);
    filter.setParent(nodeOne.getId());
    results = find(filter);
    Assert.assertEquals(1, results.size());
    Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(nodeTwo.getId())));
    // no children
    filter.setParent(nodeTwo.getId());
    results = find(filter);
    Assert.assertTrue(results.isEmpty());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) UUID(java.util.UUID) MockMvcResultMatchers.content(org.springframework.test.web.servlet.result.MockMvcResultMatchers.content) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) List(java.util.List) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) SecurityMockMvcRequestPostProcessors.authentication(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) MockMvcRequestBuilders.get(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get) Assert(org.junit.Assert) Transactional(org.springframework.transaction.annotation.Transactional) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Example 57 with IdmTreeTypeDto

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

the class IdentityRoleValidRequestSchedulerTest method createAndSaveTreeType.

private IdmTreeTypeDto createAndSaveTreeType() {
    IdmTreeTypeDto entity = new IdmTreeTypeDto();
    entity.setName("valid_tree_type_" + System.currentTimeMillis());
    entity.setCode("valid_tree_type_" + System.currentTimeMillis());
    return saveInTransaction(entity, treeTypeService);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)

Example 58 with IdmTreeTypeDto

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

the class IdentityRoleValidRequestSchedulerTest method createNonValidRole.

@Test
public void createNonValidRole() {
    IdmIdentityDto identity = createAndSaveIdentity();
    IdmRoleDto role = createAndSaveRole();
    createAndSaveRoleSystem(role, system);
    IdmTreeTypeDto treeType = createAndSaveTreeType();
    IdmTreeNodeDto treeNode = createAndSaveTreeNode(treeType);
    IdmIdentityContractDto identityContract = createAndSaveIdentityContract(identity, treeNode);
    LocalDate validFrom = new LocalDate();
    // set plus days
    validFrom = validFrom.plusDays(5);
    // provisioning is not executed
    createAndSaveIdentityRole(identityContract, role, null, validFrom);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    List<AccIdentityAccountDto> list = identityAccountService.find(filter, null).getContent();
    // it must not exists
    assertEquals(true, list.isEmpty());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) LocalDate(org.joda.time.LocalDate) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 59 with IdmTreeTypeDto

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

the class DefaultSysSystemMappingServiceTest method treeTypeIdFilterTest.

@Test
public void treeTypeIdFilterTest() {
    IdmBasePermission permission = IdmBasePermission.ADMIN;
    SystemEntityType entityType = SystemEntityType.IDENTITY;
    IdmTreeTypeDto treeType = new IdmTreeTypeDto();
    treeType.setName("SomeTreeTypeName");
    treeType.setCode("CodeCodeCodeCode");
    treeType = treeTypeService.save(treeType);
    IdmTreeTypeDto treeType2 = new IdmTreeTypeDto();
    treeType2.setName("SomeTreeTypeName2");
    treeType2.setCode("CodeCodeCodeCode2");
    treeType2 = treeTypeService.save(treeType2);
    SysSystemDto system = createSystem();
    SysSchemaObjectClassDto objectClass = createObjectClass(system);
    SysSystemMappingDto mappingSystem1 = testHelper.createMappingSystem(entityType, objectClass);
    mappingSystem1.setTreeType(treeType.getId());
    mappingSystem1 = mappingService.save(mappingSystem1);
    SysSystemMappingDto mappingSystem2 = testHelper.createMappingSystem(entityType, objectClass);
    mappingSystem2.setTreeType(treeType2.getId());
    mappingSystem2 = mappingService.save(mappingSystem2);
    SysSystemMappingFilter filter = new SysSystemMappingFilter();
    filter.setTreeTypeId(mappingSystem1.getTreeType());
    Page<SysSystemMappingDto> result = mappingService.find(filter, null, permission);
    assertEquals(1, result.getTotalElements());
    assertTrue(result.getContent().contains(mappingSystem1));
    assertFalse(result.getContent().contains(mappingSystem2));
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 60 with IdmTreeTypeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto 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)

Aggregations

IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)123 Test (org.junit.Test)91 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)89 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)64 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)44 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)33 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)32 UUID (java.util.UUID)26 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)21 IdmTreeNodeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter)21 Transactional (org.springframework.transaction.annotation.Transactional)19 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)18 SysSyncContractConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto)18 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)18 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)16 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)13 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)13 IdmIdentityContractFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter)11 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)11 LocalDate (java.time.LocalDate)10