Search in sources :

Example 26 with IdmIdentity

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

Example 27 with IdmIdentity

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());
}
Also used : IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 28 with IdmIdentity

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));
}
Also used : IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 29 with IdmIdentity

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())));
}
Also used : List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) Transactional(org.springframework.transaction.annotation.Transactional) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 30 with IdmIdentity

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

Aggregations

IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)58 Test (org.junit.Test)44 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)28 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)20 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)18 AbstractUnitTest (eu.bcvsolutions.idm.test.api.AbstractUnitTest)13 Transactional (org.springframework.transaction.annotation.Transactional)11 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)9 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)9 IdmIdentityService (eu.bcvsolutions.idm.core.api.service.IdmIdentityService)7 DataFilter (eu.bcvsolutions.idm.core.api.dto.filter.DataFilter)6 List (java.util.List)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 IdmIdentityContract (eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract)5 Assert (org.junit.Assert)5 IdmAuthorityChange (eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange)4 UUID (java.util.UUID)4 Identifiable (eu.bcvsolutions.idm.core.api.domain.Identifiable)3 IdmEntityEventDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto)3 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)3