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);
}
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());
}
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);
}
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);
}
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);
}
Aggregations