Search in sources :

Example 91 with IdmTreeTypeDto

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

the class DefaultIdmTreeNodeServiceIntegrationTest method testReferentialIntegrityDeleteNodeWithChildren.

@Transactional
@Test(expected = TreeNodeException.class)
public void testReferentialIntegrityDeleteNodeWithChildren() {
    IdmTreeTypeDto treeType = getHelper().createTreeType();
    IdmTreeNodeDto treeNode = getHelper().createTreeNode(treeType, null);
    getHelper().createTreeNode(treeType, treeNode);
    // tree node cannot be deleted, when some contract are defined on this node
    service.delete(treeNode);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 92 with IdmTreeTypeDto

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

the class DefaultIdmTreeNodeServiceIntegrationTest method testNullCode.

@Transactional
@Test(expected = ResultCodeException.class)
public void testNullCode() {
    IdmTreeTypeDto treeType = getHelper().createTreeType();
    IdmTreeNodeDto node = new IdmTreeNodeDto();
    node.setTreeType(treeType.getId());
    node.setName("test-" + getHelper().createName());
    node.setCode(null);
    service.save(node);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 93 with IdmTreeTypeDto

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

the class DefaultIdmTreeNodeServiceIntegrationTest method testBadTreeTypeUpdate.

@Test
@Transactional
public void testBadTreeTypeUpdate() {
    IdmTreeTypeDto parent1 = getHelper().createTreeType();
    IdmTreeTypeDto parent2 = getHelper().createTreeType();
    // 
    IdmTreeNodeDto node1 = getHelper().createTreeNode(parent1, null);
    IdmTreeNodeDto node2 = getHelper().createTreeNode(parent1, node1);
    IdmTreeNodeDto node3 = getHelper().createTreeNode(parent1, node2);
    // 
    node3.setTreeType(parent2.getId());
    try {
        node3 = service.save(node3);
        Assert.fail();
    } catch (TreeNodeException ex) {
        Assert.assertTrue(ex.getMessage().contains("bad type"));
    } catch (Exception e) {
        Assert.fail();
    }
    // 
    node1.setTreeType(parent2.getId());
    try {
        node1 = service.save(node1);
        Assert.fail();
    } catch (TreeNodeException ex) {
        Assert.assertTrue(ex.getMessage().contains("bad type"));
    } catch (Exception e) {
        Assert.fail();
    }
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) TreeNodeException(eu.bcvsolutions.idm.core.exception.TreeNodeException) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) TreeNodeException(eu.bcvsolutions.idm.core.exception.TreeNodeException) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 94 with IdmTreeTypeDto

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

the class DefaultIdmTreeNodeServiceIntegrationTest method testForestIndexAfterBulkMoveWithoutTransaction.

@Test
public // @Transactional - TODO: fix recount index in transaction
void testForestIndexAfterBulkMoveWithoutTransaction() {
    int rootCount = 5;
    // prepare new tree type
    IdmTreeTypeDto treeType = getHelper().createTreeType();
    // create root nodes
    for (int i = 0; i < rootCount; i++) {
        getHelper().createTreeNode(treeType, null);
    }
    // move nodes to the first node
    IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
    filter.setTreeTypeId(treeType.getId());
    List<IdmTreeNodeDto> nodes = service.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 = service.save(node);
    }
    // check
    Assert.assertEquals(1L, service.findRoots(treeType.getId(), null).getTotalElements());
    Assert.assertEquals(rootCount - 1, service.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) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 95 with IdmTreeTypeDto

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

the class DefaultIdmTreeNodeServiceIntegrationTest method testFindAllParents.

@Test
@Transactional
public void testFindAllParents() {
    // TODO: map in filter and move to rest test
    // 
    IdmTreeTypeDto treeType = getHelper().createTreeType();
    IdmTreeNodeDto node1 = getHelper().createTreeNode(treeType, null);
    IdmTreeNodeDto node2 = getHelper().createTreeNode(treeType, node1);
    IdmTreeNodeDto node3 = getHelper().createTreeNode(treeType, node2);
    getHelper().createTreeNode(treeType, node3);
    // 
    List<IdmTreeNodeDto> parents = service.findAllParents(node3.getId(), null);
    // 
    Assert.assertEquals(2, parents.size());
    Assert.assertTrue(parents.stream().anyMatch(n -> n.equals(node1)));
    Assert.assertTrue(parents.stream().anyMatch(n -> n.equals(node2)));
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) Lists(org.testng.collections.Lists) ProcessAutomaticRoleByTreeTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ProcessAutomaticRoleByTreeTaskExecutor) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) AutomaticRoleManager(eu.bcvsolutions.idm.core.api.service.AutomaticRoleManager) AutowireHelper(eu.bcvsolutions.idm.core.api.utils.AutowireHelper) EntityStateManager(eu.bcvsolutions.idm.core.api.service.EntityStateManager) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) ForestIndexService(eu.bcvsolutions.forest.index.service.api.ForestIndexService) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) IdmTreeNodeForestContentService(eu.bcvsolutions.idm.core.model.service.api.IdmTreeNodeForestContentService) Before(org.junit.Before) IdmForestIndexEntity(eu.bcvsolutions.idm.core.model.entity.IdmForestIndexEntity) IdmIdentityRoleService(eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService) RecursionType(eu.bcvsolutions.idm.core.api.domain.RecursionType) LongRunningTaskManager(eu.bcvsolutions.idm.core.scheduler.api.service.LongRunningTaskManager) TreeNodeEvent(eu.bcvsolutions.idm.core.model.event.TreeNodeEvent) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LongRunningFutureTask(eu.bcvsolutions.idm.core.scheduler.api.dto.LongRunningFutureTask) ProcessSkippedAutomaticRoleByTreeTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ProcessSkippedAutomaticRoleByTreeTaskExecutor) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) IdmEntityStateFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter) TreeNodeException(eu.bcvsolutions.idm.core.exception.TreeNodeException) UUID(java.util.UUID) ApplicationContext(org.springframework.context.ApplicationContext) IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmTreeNode(eu.bcvsolutions.idm.core.model.entity.IdmTreeNode) List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) LocalDate(java.time.LocalDate) TreeNodeEventType(eu.bcvsolutions.idm.core.model.event.TreeNodeEvent.TreeNodeEventType) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ProcessAllAutomaticRoleByTreeTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ProcessAllAutomaticRoleByTreeTaskExecutor) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) Transactional(org.springframework.transaction.annotation.Transactional) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

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