use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter in project CzechIdMng by bcvsolutions.
the class IdentityFilterTest method testRecursivelyFilter.
@Test
public void testRecursivelyFilter() {
// setting employees
IdmIdentityDto person1 = getIdmIdentity("Klement", "Marek", "ThisIsTestName011@gemail.eu", "000000011", false);
IdmIdentityDto person2 = getIdmIdentity("Klement", "Marek", "ThisIsTestName014@gemail.eu", "000000014", false);
IdmIdentityDto person3 = getIdmIdentity("Klement", "Marek", "ThisIsTestName015@gemail.eu", "000000015", false);
IdmIdentityDto person4 = getIdmIdentity("Klement", "Marek", "ThisIsTestName016@gemail.eu", "000000016", false);
// setting structure
IdmTreeTypeDto type1 = helper.createTreeType("ThisIsTestType005x");
IdmTreeTypeDto type2 = helper.createTreeType("ThisIsTestType006x");
/*
r1 o
/
n1 o
/
n2 o
*/
IdmTreeNodeDto node1 = helper.createTreeNode(type1, "ThisIsTestNode005", null);
IdmTreeNodeDto node11 = helper.createTreeNode(type1, "ThisIsTestNode006", node1);
IdmTreeNodeDto node12 = helper.createTreeNode(type1, "ThisIsTestNode007", node11);
/*
r2 o
*/
IdmTreeNodeDto node2 = helper.createTreeNode(type2, "ThisIsTestNode008", null);
// contracts
helper.createIdentityContact(person1, node1);
helper.createIdentityContact(person2, node11);
helper.createIdentityContact(person3, node12);
helper.createIdentityContact(person4, node2);
// node1 UUID
UUID node1id = node1.getId();
// test
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setFirstName(person1.getFirstName());
filter.setRecursively(true);
filter.setTreeNode(node1id);
Page<IdmIdentityDto> result = identityService.find(filter, null);
assertEquals("Wrong Recursive firstname", 4, result.getTotalElements());
filter.setRecursively(false);
result = identityService.find(filter, null);
assertEquals("Wrong NonRecursive firstname", 1, result.getTotalElements());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter in project CzechIdMng by bcvsolutions.
the class IdentityFilterTest method testRoleFilter.
@Test
public void testRoleFilter() {
IdmIdentityDto person = getIdmIdentity("ThisIsTestName013", "ThisIsTestName013", "ThisIsTestName013@gemail.eu", "100000013", false);
IdmTreeTypeDto type = helper.createTreeType("ThisIsTestType007");
IdmTreeNodeDto node = helper.createTreeNode(type, "ThisIsTestNode008", null);
IdmIdentityContractDto contract = helper.createIdentityContact(person, node);
IdmRoleDto somerole = helper.createRole();
helper.createIdentityRole(contract, somerole);
UUID roleId = somerole.getId();
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setRoles(Collections.singletonList(roleId));
Page<IdmIdentityDto> result = identityService.find(filter, null);
assertEquals("Wrong Roles", 1, result.getTotalElements());
assertEquals("Wrong Roles user ID", person.getId(), result.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter in project CzechIdMng by bcvsolutions.
the class IdentityFilterTest method testStateFilter.
@Test
public void testStateFilter() {
String firstname = helper.createName();
IdmIdentityDto identityOne = new IdmIdentityDto();
identityOne.setUsername(helper.createName());
identityOne.setFirstName(firstname);
identityOne = identityService.save(identityOne);
identityContractService.delete(helper.getPrimeContract(identityOne.getId()));
IdmIdentityDto identity = new IdmIdentityDto();
identity.setUsername(helper.createName());
identity.setFirstName(firstname);
identity.setState(IdentityState.DISABLED_MANUALLY);
identityService.save(identity);
//
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setFirstName(firstname);
filter.setState(IdentityState.VALID);
Page<IdmIdentityDto> results = identityService.find(filter, null);
Assert.assertTrue(results.getTotalElements() == 0);
//
filter.setState(IdentityState.NO_CONTRACT);
results = identityService.find(filter, null);
Assert.assertTrue(results.getTotalElements() == 1);
Assert.assertEquals(identityOne.getUsername(), results.getContent().get(0).getUsername());
//
filter.setState(IdentityState.DISABLED_MANUALLY);
results = identityService.find(filter, null);
Assert.assertTrue(results.getTotalElements() == 1);
Assert.assertEquals(identity.getUsername(), results.getContent().get(0).getUsername());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter in project CzechIdMng by bcvsolutions.
the class DefaultVsRequestService method getIdentity.
private IdmIdentityDto getIdentity(VsRequestDto request) {
if (request == null) {
return null;
}
// We assume the request.UID is equals Identity user name!;
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setUsername(request.getUid());
List<IdmIdentityDto> identities = this.identityService.find(filter, null).getContent();
if (identities.isEmpty()) {
return null;
}
return identities.get(0);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter in project CzechIdMng by bcvsolutions.
the class AbstractWorkingPositionFilterIntegrationTest method testManagersBuilder.
protected void testManagersBuilder(FilterBuilder<IdmIdentity, IdmIdentityFilter> builder) {
//
// tests
// all managers - for subordinate one
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setManagersFor(subordinateOne.getId());
filter.setIncludeGuarantees(true);
List<IdmIdentity> managers = builder.find(filter, null).getContent();
assertTrue(contains(managers, managerOne));
assertTrue(contains(managers, managerTwo));
assertTrue(contains(managers, guaranteeThree));
assertTrue(contains(managers, guaranteeFour));
assertEquals(4, managers.size());
//
// find contract managers
filter = new IdmIdentityFilter();
filter.setManagersFor(subordinateOne.getId());
filter.setManagersByContract(contractOne.getId());
managers = builder.find(filter, null).getContent();
assertEquals(2, managers.size());
assertTrue(contains(managers, managerOne));
assertTrue(contains(managers, guaranteeThree));
//
// find contract managers by without guarantees
filter = new IdmIdentityFilter();
filter.setManagersFor(subordinateOne.getId());
filter.setManagersByContract(contractOne.getId());
filter.setIncludeGuarantees(false);
managers = builder.find(filter, null).getContent();
assertEquals(1, managers.size());
assertTrue(contains(managers, managerOne));
//
// manager by tree structures
filter = new IdmIdentityFilter();
filter.setManagersFor(subordinateOne.getId());
filter.setManagersByTreeType(structureOne.getId());
managers = builder.find(filter, null).getContent();
assertEquals(1, managers.size());
assertTrue(contains(managers, managerOne));
filter.setManagersByTreeType(structureTwo.getId());
managers = builder.find(filter, null).getContent();
assertEquals(1, managers.size());
assertTrue(contains(managers, managerTwo));
//
// all manager - for subordinate one
filter = new IdmIdentityFilter();
filter.setManagersFor(subordinateTwo.getId());
managers = builder.find(filter, null).getContent();
assertEquals(2, managers.size());
assertTrue(contains(managers, subordinateOne));
assertTrue(contains(managers, guaranteeFour));
}
Aggregations