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