Search in sources :

Example 31 with IdmTreeNodeDto

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

the class IdmTreeNodeServiceIntegrationTest method testReferentialIntegrity.

@Test(expected = ResultCodeException.class)
public void testReferentialIntegrity() {
    IdmIdentityDto identity = helper.createIdentity();
    IdmTreeNodeDto treeNode = helper.createTreeNode();
    helper.createIdentityContact(identity, treeNode);
    // tree node cannot be deleted, when some contract are defined on this node
    treeNodeService.delete(treeNode);
}
Also used : 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 32 with IdmTreeNodeDto

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

the class IdmTreeNodeServiceIntegrationTest method testForestIndexAfterBulkMove.

@Test
public void testForestIndexAfterBulkMove() {
    int rootCount = 5;
    // prepare new tree type
    IdmTreeTypeDto treeType = helper.createTreeType();
    // create root nodes
    for (int i = 0; i < rootCount; i++) {
        helper.createTreeNode(treeType, null);
    }
    // move nodes to the first node
    IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
    filter.setTreeTypeId(treeType.getId());
    List<IdmTreeNodeDto> nodes = treeNodeService.find(filter, null).getContent();
    IdmTreeNodeDto root = nodes.get(0);
    for (int i = 0; i < nodes.size(); i++) {
        IdmTreeNodeDto node = nodes.get(i);
        if (node.equals(root)) {
            continue;
        }
        node.setParent(root.getId());
        node = treeNodeService.save(node);
    }
    // check
    Assert.assertEquals(1L, treeNodeService.findRoots(treeType.getId(), null).getTotalElements());
    Assert.assertEquals(rootCount - 1, treeNodeService.findChildrenByParent(root.getId(), null).getTotalElements());
    Assert.assertEquals(rootCount - 1, treeNodeForestContentService.findDirectChildren(root.getId(), null).getTotalElements());
    Assert.assertEquals(rootCount - 1, treeNodeForestContentService.findAllChildren(root.getId(), null).getTotalElements());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 33 with IdmTreeNodeDto

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

the class SendNotificationToApplicantAndImplementerTest method createStructure.

/**
 * Creates organization's structure and identity testUser2 as manager
 */
private void createStructure() {
    IdmRoleDto superAdminRole = this.roleService.getByCode(InitApplicationData.ADMIN_ROLE);
    IdmTreeNodeDto rootOrganization = treeNodeService.findRoots((UUID) null, new PageRequest(0, 1)).getContent().get(0);
    IdmRoleDto role2 = new IdmRoleDto();
    role2.setName("TestCustomRole002" + System.currentTimeMillis());
    List<IdmRoleCompositionDto> subRoles = new ArrayList<>();
    subRoles.add(new IdmRoleCompositionDto(role2.getId(), superAdminRole.getId()));
    role2.setSubRoles(subRoles);
    role2 = this.roleService.save(role2);
    testUser2 = new IdmIdentityDto();
    testUser2.setUsername("Test_user_Manager" + System.currentTimeMillis());
    testUser2.setPassword(new GuardedString("heslo"));
    testUser2.setFirstName("Test");
    testUser2.setLastName("Second User");
    testUser2.setEmail("test2@bscsolutions.eu");
    testUser2 = this.identityService.save(testUser2);
    IdmTreeTypeDto type = treeTypeService.get(rootOrganization.getTreeType());
    organization = new IdmTreeNodeDto();
    organization.setCode("test" + System.currentTimeMillis());
    organization.setName("Organization Test Notification");
    organization.setParent(rootOrganization.getId());
    organization.setTreeType(type.getId());
    organization = this.treeNodeService.save(organization);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) PageRequest(org.springframework.data.domain.PageRequest) 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)

Example 34 with IdmTreeNodeDto

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

the class DefaultTestHelper method createTreeNode.

@Override
public IdmTreeNodeDto createTreeNode(IdmTreeTypeDto treeType, String name, IdmTreeNodeDto parent) {
    Assert.notNull(treeType, "Tree type is required - test environment is wrong configured, test data is not prepared!");
    // 
    name = name == null ? createName() : name;
    IdmTreeNodeDto node = new IdmTreeNodeDto();
    node.setParent(parent == null ? null : parent.getId());
    node.setCode(name);
    node.setName(name);
    node.setTreeType(treeType.getId());
    // 
    return treeNodeService.save(node);
}
Also used : IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)

Example 35 with IdmTreeNodeDto

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

the class DefaultIdmAutomaticRoleAttributeIntegrationTest method testUpdateWithoutAutomaticRoles.

@Test
public void testUpdateWithoutAutomaticRoles() {
    IdmIdentityDto identity = testHelper.createIdentity();
    IdmIdentityContractDto primeContract = testHelper.getPrimeContract(identity.getId());
    IdmRoleDto basicRole = testHelper.createRole();
    testHelper.assignRoles(primeContract, basicRole);
    IdmTreeTypeDto type = testHelper.createTreeType();
    IdmTreeNodeDto node = testHelper.createTreeNode(type, null);
    primeContract.setWorkPosition(node.getId());
    identity.setDescription(String.valueOf(System.currentTimeMillis()));
    identityContractService.save(primeContract);
    identityService.save(identity);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) 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)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