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