Search in sources :

Example 16 with IdmIdentityFilter

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());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 17 with IdmIdentityFilter

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());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 18 with IdmIdentityFilter

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());
}
Also used : IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 19 with IdmIdentityFilter

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);
}
Also used : IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)

Example 20 with IdmIdentityFilter

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));
}
Also used : IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity)

Aggregations

IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)39 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)31 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)26 Test (org.junit.Test)26 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)9 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)8 UUID (java.util.UUID)7 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)6 SysSyncIdentityConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto)5 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)5 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)5 DefaultSynchronizationServiceTest (eu.bcvsolutions.idm.acc.service.impl.DefaultSynchronizationServiceTest)5 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)5 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)5 PageRequest (org.springframework.data.domain.PageRequest)5 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)4 Sort (org.springframework.data.domain.Sort)3 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)2 IdmScriptAuthorityDto (eu.bcvsolutions.idm.core.api.dto.IdmScriptAuthorityDto)2 IdmScriptDto (eu.bcvsolutions.idm.core.api.dto.IdmScriptDto)2