use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity 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, managerThree));
assertTrue(contains(managers, guaranteeThree));
assertTrue(contains(managers, guaranteeFour));
assertTrue(contains(managers, guaranteeFive));
assertEquals(6, managers.size());
//
filter = new IdmIdentityFilter();
filter.setManagersFor(subordinateOne.getId());
filter.setIncludeGuarantees(true);
filter.setValidContractManagers(Boolean.TRUE);
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());
//
filter = new IdmIdentityFilter();
filter.setManagersFor(subordinateOne.getId());
filter.setIncludeGuarantees(true);
filter.setValidContractManagers(Boolean.FALSE);
managers = builder.find(filter, null).getContent();
assertTrue(contains(managers, managerThree));
assertTrue(contains(managers, guaranteeFive));
assertEquals(2, 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());
filter.setValidContractManagers(Boolean.TRUE);
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 two
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));
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class GuaranteeSubordinatesFilterIntegrationTest method testSubordinates.
@Test
@Transactional
public void testSubordinates() {
prepareData();
//
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setSubordinatesFor(managerOne.getId());
filter.setIncludeGuarantees(false);
List<IdmIdentity> subordinates = builder.find(filter, null).getContent();
assertTrue(subordinates.isEmpty());
//
filter = new IdmIdentityFilter();
filter.setSubordinatesFor(managerOne.getId());
filter.setIncludeGuarantees(true);
subordinates = builder.find(filter, null).getContent();
assertTrue(contains(subordinates, subordinateThree));
assertEquals(1, subordinates.size());
//
filter = new IdmIdentityFilter();
filter.setSubordinatesFor(managerOne.getId());
filter.setSubordinatesByTreeType(structureOne.getId());
subordinates = builder.find(filter, null).getContent();
assertTrue(subordinates.isEmpty());
//
filter = new IdmIdentityFilter();
filter.setSubordinatesFor(invalidManagerExpiredContract.getId());
subordinates = builder.find(filter, null).getContent();
assertTrue(subordinates.isEmpty());
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class GuaranteeManagersFilterBuilderIntegrationTest method testManagers.
@Test
@Transactional
public void testManagers() {
prepareData();
//
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setManagersFor(subordinateOne.getId());
filter.setIncludeGuarantees(true);
List<IdmIdentity> managers = builder.find(filter, null).getContent();
assertTrue(contains(managers, guaranteeThree));
assertTrue(contains(managers, guaranteeFour));
assertTrue(contains(managers, guaranteeFive));
assertEquals(3, managers.size());
//
filter = new IdmIdentityFilter();
filter.setManagersFor(subordinateOne.getId());
filter.setIncludeGuarantees(true);
filter.setValidContractManagers(Boolean.TRUE);
managers = builder.find(filter, null).getContent();
assertTrue(contains(managers, guaranteeThree));
assertTrue(contains(managers, guaranteeFour));
assertEquals(2, managers.size());
//
filter.setValidContractManagers(Boolean.FALSE);
managers = builder.find(filter, null).getContent();
assertTrue(contains(managers, guaranteeFive));
assertEquals(1, managers.size());
//
// find contract managers
filter = new IdmIdentityFilter();
filter.setManagersFor(subordinateOne.getId());
filter.setManagersByContract(contractOne.getId());
managers = builder.find(filter, null).getContent();
assertEquals(1, managers.size());
assertTrue(contains(managers, guaranteeThree));
//
// find contract managers by without guarantees
filter = new IdmIdentityFilter();
filter.setManagersFor(subordinateOne.getId());
filter.setIncludeGuarantees(false);
managers = builder.find(filter, null).getContent();
assertTrue(managers.isEmpty());
//
// manager by tree structures
filter = new IdmIdentityFilter();
filter.setManagersFor(subordinateOne.getId());
filter.setManagersByTreeType(structureOne.getId());
assertTrue(managers.isEmpty());
//
// all manager - for subordinate one
filter = new IdmIdentityFilter();
filter.setManagersFor(subordinateTwo.getId());
managers = builder.find(filter, null).getContent();
assertEquals(1, managers.size());
assertTrue(contains(managers, guaranteeFour));
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class IdentityGuaranteesForRoleFilterIntegrationTest method testFindGuaranteesByTypeInIdentity.
@Test
public void testFindGuaranteesByTypeInIdentity() {
// prepare data
String guaranteeType = getHelper().createName();
IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityThree = getHelper().createIdentity((GuardedString) null);
IdmRoleDto role = getHelper().createRole();
IdmRoleDto roleGuarantee = getHelper().createRole();
getHelper().createRoleGuarantee(role, identityOne);
getHelper().createRoleGuaranteeRole(role, roleGuarantee, guaranteeType);
getHelper().createIdentityRole(identityThree, roleGuarantee);
getHelper().createIdentityRole(identityTwo, role);
//
IdmIdentityFilter dataFilter = new IdmIdentityFilter();
dataFilter.setGuaranteesForRole(role.getId());
dataFilter.setGuaranteeType(guaranteeType);
List<IdmIdentity> identities = filter.find(dataFilter, null).getContent();
//
Assert.assertEquals(1, identities.size());
Assert.assertTrue(identities.stream().anyMatch(i -> i.getId().equals(identityThree.getId())));
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class IdentityGuaranteesForRoleFilterIntegrationTest method testFindGuaranteesByWrongTypeInIdentityAndRole.
@Test
public void testFindGuaranteesByWrongTypeInIdentityAndRole() {
// prepare data
String guaranteeType = getHelper().createName();
IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityThree = getHelper().createIdentity((GuardedString) null);
IdmRoleDto role = getHelper().createRole();
IdmRoleDto roleGuarantee = getHelper().createRole();
getHelper().createRoleGuarantee(role, identityOne, guaranteeType);
getHelper().createRoleGuaranteeRole(role, roleGuarantee, guaranteeType);
getHelper().createIdentityRole(identityThree, roleGuarantee);
getHelper().createIdentityRole(identityTwo, role);
//
IdmIdentityFilter dataFilter = new IdmIdentityFilter();
dataFilter.setGuaranteesForRole(role.getId());
// Set no exists guarantee type
dataFilter.setGuaranteeType(getHelper().createName());
List<IdmIdentity> identities = filter.find(dataFilter, null).getContent();
//
Assert.assertEquals(0, identities.size());
}
Aggregations