use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto 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();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testFindTreeNodesByNullAttributeValue.
@Test
public void testFindTreeNodesByNullAttributeValue() {
IdmTreeNodeDto owner = helper.createTreeNode();
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmTreeNode.class);
IdmFormAttributeDto attribute = formDefinition.getFormAttributes().get(0);
// save values
formService.saveValues(owner.getId(), IdmTreeNode.class, attribute, Lists.newArrayList(FORM_VALUE_ONE));
//
Page<? extends Identifiable> owners = formService.findOwners(IdmTreeNode.class, attribute, FORM_VALUE_ONE, null);
//
assertEquals(1, owners.getTotalElements());
assertEquals(owner.getId(), owners.getContent().get(0).getId());
//
owners = formService.findOwners(IdmTreeNode.class, attribute.getCode(), null, null);
assertEquals(0, owners.getTotalElements());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdentityFilterTest method testIncludeGuaranteesFilter.
@Test
public void testIncludeGuaranteesFilter() {
IdmIdentityDto person = getIdmIdentity("aThisIsTestName009", "ThisIsTestName009", "ThisIsTestName009@gemail.eu", "000000009", false);
IdmIdentityDto manager2 = getIdmIdentity("manager009", "ThisIsTestName009", "ThisIsTestName009@gemail.eu", "000000009", false);
IdmIdentityDto manager = getIdmIdentity("ThisIsTestName010", "ThisIsTestName010", "ThisIsTestName010@gemail.eu", "000000010", false);
IdmTreeTypeDto type1 = helper.createTreeType("ThisIsTestType0004");
IdmTreeNodeDto node1 = helper.createTreeNode(type1, "ThisIsTestNode0004", null);
IdmTreeNodeDto node2 = helper.createTreeNode(type1, "NextThisIsTestNode0004", node1);
IdmIdentityContractDto contract = helper.createIdentityContact(person, node2);
helper.createContractGuarantee(contract.getId(), manager2.getId());
helper.createIdentityContact(manager, node1);
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setManagersFor(person.getId());
filter.setIncludeGuarantees(true);
Page<IdmIdentityDto> result = identityService.find(filter, null);
assertEquals("Wrong Managers2For", 2, result.getTotalElements());
filter.setIncludeGuarantees(false);
result = identityService.find(filter, null);
assertEquals("Wrong Managers2For test 2", 1, result.getTotalElements());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdentityFilterTest method testSameButDifferentTreeTypeFilter.
@Test
public void testSameButDifferentTreeTypeFilter() {
IdmIdentityDto person1 = getIdmIdentity("thistn01", "thistn01", "thistn02@a.eu", "000010001", false);
getIdmIdentity("thistn01", "thistn01", "thistn02@a.eu", "000010001", false);
IdmTreeTypeDto type1 = helper.createTreeType("typeName001");
IdmTreeTypeDto type2 = helper.createTreeType("typeName002");
IdmTreeNodeDto node1 = helper.createTreeNode(type1, "nodeName001", null);
helper.createTreeNode(type2, "nodeName002", null);
helper.createIdentityContact(person1, node1);
helper.createIdentityContact(person1, node1);
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setFirstName(person1.getFirstName());
Page<IdmIdentityDto> result = identityService.find(filter, null);
assertEquals("Wrong sameButDiff filter", 2, result.getTotalElements());
filter.setTreeType(type1.getId());
result = identityService.find(filter, null);
assertEquals("Wrong sameButDiff filter 2", 1, result.getTotalElements());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdentityFilterTest method testTreeTypeFilter.
@Test
public void testTreeTypeFilter() {
IdmIdentityDto person = getIdmIdentity("ThisIsTestName007", "ThisIsTestName007", "ThisIsTestName007@gemail.eu", "000000007", false);
IdmTreeTypeDto type = helper.createTreeType("ThisIsTestType002");
IdmTreeNodeDto node = helper.createTreeNode(type, "ThisIsTestNode002", null);
UUID typeUuid = type.getId();
helper.createIdentityContact(person, node);
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setTreeType(typeUuid);
Page<IdmIdentityDto> result = identityService.find(filter, null);
assertEquals("Wrong TreeType", 1, result.getTotalElements());
}
Aggregations