Search in sources :

Example 26 with IdmIdentityFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangeManagersContract.

/**
 * Call provisioning for subordinates, after managers's contract changes - filled managers could be provisioned
 */
@Test
public void doIdentityProvisioningChangeManagersContract() {
    IdmIdentityDto managerOne = createIdentity();
    IdmIdentityDto subordinateOne = createIdentity();
    IdmTreeNodeDto managerOnePosition = createTreeNode(null);
    IdmIdentityContractDto managersContract = createIdentityContact(managerOne, managerOnePosition);
    IdmTreeNodeDto subordinateOnePositionOne = createTreeNode(managerOnePosition);
    createIdentityContact(subordinateOne, subordinateOnePositionOne);
    AccIdentityAccountDto subordinateAccount = prepareAccount(subordinateOne);
    // 
    provisioningService.doProvisioning(DtoUtils.getEmbedded(subordinateAccount, AccIdentityAccount_.identity, IdmIdentityDto.class));
    // 
    TestResource account = entityManager.find(TestResource.class, accountService.get(subordinateAccount.getAccount()).getUid());
    Assert.assertNotNull(account);
    Assert.assertEquals(subordinateOne.getFirstName(), account.getFirstname());
    // 
    IdmIdentityFilter filter = new IdmIdentityFilter();
    filter.setSubordinatesFor(managerOne.getId());
    List<IdmIdentityDto> subordinates = idmIdentityService.find(filter, null).getContent();
    Assert.assertEquals(1, subordinates.size());
    Assert.assertEquals(subordinateOne.getId(), subordinates.get(0).getId());
    // 
    // change subordinate
    subordinateOne.setFirstName("first-name-change-one");
    subordinateOne = idmIdentityService.saveInternal(subordinateOne);
    // 
    // change managers contract
    managersContract.setWorkPosition(null);
    managersContract = identityContractService.save(managersContract);
    // 
    account = entityManager.find(TestResource.class, accountService.get(subordinateAccount.getAccount()).getUid());
    Assert.assertNotNull(account);
    Assert.assertEquals(subordinateOne.getFirstName(), account.getFirstname());
    subordinates = idmIdentityService.find(filter, null).getContent();
    Assert.assertEquals(0, subordinates.size());
    // 
    // change subordinate again
    subordinateOne.setFirstName("first-name-change-two");
    subordinateOne = idmIdentityService.saveInternal(subordinateOne);
    // 
    managersContract.setWorkPosition(managerOnePosition.getId());
    managersContract = identityContractService.save(managersContract);
    // 
    account = entityManager.find(TestResource.class, accountService.get(subordinateAccount.getAccount()).getUid());
    Assert.assertNotNull(account);
    Assert.assertEquals(subordinateOne.getFirstName(), account.getFirstname());
    subordinates = idmIdentityService.find(filter, null).getContent();
    Assert.assertEquals(1, subordinates.size());
    Assert.assertEquals(subordinateOne.getId(), subordinates.get(0).getId());
}
Also used : IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 27 with IdmIdentityFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter in project CzechIdMng by bcvsolutions.

the class AbstractWorkingPositionFilterIntegrationTest method testSubordinatesBuilder.

protected void testSubordinatesBuilder(FilterBuilder<IdmIdentity, IdmIdentityFilter> builder) {
    IdmIdentityFilter filter = new IdmIdentityFilter();
    filter.setSubordinatesFor(managerOne.getId());
    List<IdmIdentity> subordinates = builder.find(filter, null).getContent();
    assertEquals(2, subordinates.size());
    assertTrue(contains(subordinates, subordinateOne));
    assertTrue(contains(subordinates, subordinateThree));
    // 
    filter = new IdmIdentityFilter();
    filter.setSubordinatesFor(managerOne.getId());
    filter.setSubordinatesByTreeType(structureOne.getId());
    subordinates = builder.find(filter, null).getContent();
    assertEquals(1, subordinates.size());
    assertTrue(contains(subordinates, subordinateOne));
    // 
    filter = new IdmIdentityFilter();
    filter.setSubordinatesFor(guaranteeFour.getId());
    subordinates = builder.find(filter, null).getContent();
    assertEquals(2, subordinates.size());
    assertTrue(contains(subordinates, subordinateOne));
    assertTrue(contains(subordinates, subordinateTwo));
    // 
    filter = new IdmIdentityFilter();
    filter.setSubordinatesFor(invalidManager.getId());
    subordinates = builder.find(filter, null).getContent();
    assertTrue(subordinates.isEmpty());
}
Also used : IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity)

Example 28 with IdmIdentityFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter in project CzechIdMng by bcvsolutions.

the class IdentityFilterTest method testLastnameFilter.

@Test
public void testLastnameFilter() {
    IdmIdentityDto person = getIdmIdentity("ThisIsTestName003", "ThisIsTestName003", "ThisIsTestName003@gemail.eu", "000000003", false);
    IdmIdentityFilter filter = new IdmIdentityFilter();
    filter.setLastName(person.getLastName());
    Page<IdmIdentityDto> result = identityService.find(filter, null);
    assertEquals("Wrong Lastname", 1, result.getTotalElements());
    assertEquals("Wrong Lastname user ID", person.getId(), result.getContent().get(0).getId());
}
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 29 with IdmIdentityFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter 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());
}
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) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 30 with IdmIdentityFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter in project CzechIdMng by bcvsolutions.

the class IdentityFilterTest method testDisabledFilter.

@Test
public void testDisabledFilter() {
    IdmIdentityDto person = getIdmIdentity("ThisIsTestName004", "ThisIsTestName004", "ThisIsTestName004@gemail.eu", "000000004", false);
    IdmIdentityFilter filter = new IdmIdentityFilter();
    filter.setDisabled(false);
    Page<IdmIdentityDto> result = identityService.find(filter, null);
    person.setState(IdentityState.DISABLED);
    identityService.save(person);
    filter.setDisabled(false);
    Page<IdmIdentityDto> result2 = identityService.find(filter, null);
    int changed = (int) (result.getTotalElements() - result2.getTotalElements());
    assertEquals("Wrong Disabled", 1, changed);
}
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)

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