Search in sources :

Example 1 with IdmRoleGuaranteeFilter

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

the class RoleExportBulkActionIntegrationTest method findGuarantees.

private List<IdmRoleGuaranteeDto> findGuarantees(IdmRoleDto role) {
    IdmRoleGuaranteeFilter filter = new IdmRoleGuaranteeFilter();
    filter.setRole(role.getId());
    return roleGuaranteeService.find(filter, null).getContent();
}
Also used : IdmRoleGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter)

Example 2 with IdmRoleGuaranteeFilter

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

the class DefaultIdmRoleGuaranteeServiceIntegrationTest method testFindRoleGuaranteeByGuarantee.

@Test
public void testFindRoleGuaranteeByGuarantee() {
    IdmIdentityDto guarantee = getHelper().createIdentity((GuardedString) null);
    // 
    IdmRoleDto role1 = getHelper().createRole();
    IdmRoleDto role2 = getHelper().createRole();
    IdmRoleDto role3 = getHelper().createRole();
    // 
    IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
    roleGuarantee.setRole(role1.getId());
    roleGuarantee.setGuarantee(guarantee.getId());
    roleGuaranteeService.save(roleGuarantee);
    // 
    roleGuarantee = new IdmRoleGuaranteeDto();
    roleGuarantee.setRole(role2.getId());
    roleGuarantee.setGuarantee(guarantee.getId());
    roleGuaranteeService.save(roleGuarantee);
    // 
    roleGuarantee = new IdmRoleGuaranteeDto();
    roleGuarantee.setRole(role3.getId());
    roleGuarantee.setGuarantee(guarantee.getId());
    roleGuaranteeService.save(roleGuarantee);
    // 
    IdmRoleGuaranteeFilter filter = new IdmRoleGuaranteeFilter();
    filter.setGuarantee(guarantee.getId());
    List<IdmRoleGuaranteeDto> list = roleGuaranteeService.find(filter, null).getContent();
    Assert.assertEquals(3, list.size());
    // 
    List<UUID> roles = list.stream().map(IdmRoleGuaranteeDto::getRole).collect(Collectors.toList());
    roleGuarantee = list.get(0);
    Assert.assertEquals(guarantee.getId(), roleGuarantee.getGuarantee());
    Assert.assertTrue(roles.contains(role1.getId()));
    Assert.assertTrue(roles.contains(role2.getId()));
    Assert.assertTrue(roles.contains(role3.getId()));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto) IdmRoleGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 3 with IdmRoleGuaranteeFilter

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

the class DefaultIdmRoleGuaranteeServiceIntegrationTest method testFindRoleGuaranteeByGuaranteeAndType.

@Test
public void testFindRoleGuaranteeByGuaranteeAndType() {
    IdmRoleDto role1 = getHelper().createRole();
    IdmRoleDto role2 = getHelper().createRole();
    // 
    IdmIdentityDto guarantee = getHelper().createIdentity((GuardedString) null);
    String guarranteeType = getHelper().createName();
    getHelper().createRoleGuarantee(role1, guarantee, guarranteeType);
    getHelper().createRoleGuarantee(role2, guarantee, null);
    // 
    IdmRoleGuaranteeFilter filter = new IdmRoleGuaranteeFilter();
    filter.setGuarantee(guarantee.getId());
    filter.setType(guarranteeType);
    List<IdmRoleGuaranteeDto> list = roleGuaranteeService.find(filter, null).getContent();
    Assert.assertEquals(1, list.size());
    // 
    IdmRoleGuaranteeDto roleGuaranteeFirst = list.get(0);
    Assert.assertEquals(guarantee.getId(), roleGuaranteeFirst.getGuarantee());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto) IdmRoleGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 4 with IdmRoleGuaranteeFilter

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

the class DefaultIdmRoleGuaranteeServiceIntegrationTest method testFindRoleGuaranteeByRole.

@Test
public void testFindRoleGuaranteeByRole() {
    IdmIdentityDto guarantee1 = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto guarantee2 = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto guarantee3 = getHelper().createIdentity((GuardedString) null);
    // 
    IdmRoleDto role = getHelper().createRole();
    // 
    IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
    roleGuarantee.setRole(role.getId());
    roleGuarantee.setGuarantee(guarantee1.getId());
    roleGuaranteeService.save(roleGuarantee);
    // 
    roleGuarantee = new IdmRoleGuaranteeDto();
    roleGuarantee.setRole(role.getId());
    roleGuarantee.setGuarantee(guarantee2.getId());
    roleGuaranteeService.save(roleGuarantee);
    // 
    roleGuarantee = new IdmRoleGuaranteeDto();
    roleGuarantee.setRole(role.getId());
    roleGuarantee.setGuarantee(guarantee3.getId());
    roleGuaranteeService.save(roleGuarantee);
    // 
    IdmRoleGuaranteeFilter filter = new IdmRoleGuaranteeFilter();
    filter.setRole(role.getId());
    List<IdmRoleGuaranteeDto> list = roleGuaranteeService.find(filter, null).getContent();
    Assert.assertEquals(3, list.size());
    // 
    List<UUID> guarantees = list.stream().map(IdmRoleGuaranteeDto::getGuarantee).collect(Collectors.toList());
    roleGuarantee = list.get(0);
    Assert.assertEquals(role.getId(), roleGuarantee.getRole());
    Assert.assertTrue(guarantees.contains(guarantee3.getId()));
    Assert.assertTrue(guarantees.contains(guarantee2.getId()));
    Assert.assertTrue(guarantees.contains(guarantee1.getId()));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto) IdmRoleGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 5 with IdmRoleGuaranteeFilter

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

the class DefaultIdmRoleServiceIntegrationTest method testReferentialIntegrity.

@Test
public void testReferentialIntegrity() {
    IdmIdentityDto identity = getHelper().createIdentity(new GuardedString("heslo"));
    // role
    IdmRoleDto role = getHelper().createRole();
    getHelper().createRoleGuarantee(role, identity);
    // 
    // guarantee by role
    IdmRoleGuaranteeRoleDto roleGuaranteeOne = new IdmRoleGuaranteeRoleDto();
    roleGuaranteeOne.setRole(role.getId());
    roleGuaranteeOne.setGuaranteeRole(getHelper().createRole().getId());
    roleGuaranteeRoleService.save(roleGuaranteeOne);
    IdmRoleGuaranteeRoleDto roleGuaranteeTwo = new IdmRoleGuaranteeRoleDto();
    roleGuaranteeTwo.setRole(getHelper().createRole().getId());
    roleGuaranteeTwo.setGuaranteeRole(role.getId());
    roleGuaranteeRoleService.save(roleGuaranteeTwo);
    // 
    // after save
    IdmRoleGuaranteeFilter guaranteeFilter = new IdmRoleGuaranteeFilter();
    guaranteeFilter.setRole(role.getId());
    IdmRoleGuaranteeRoleFilter guaranteeRoleFilter = new IdmRoleGuaranteeRoleFilter();
    guaranteeRoleFilter.setRole(role.getId());
    IdmRoleGuaranteeRoleFilter guaranteeRoleRoleFilter = new IdmRoleGuaranteeRoleFilter();
    guaranteeRoleRoleFilter.setGuaranteeRole(role.getId());
    // 
    Assert.assertNotNull(roleService.getByCode(role.getCode()));
    Assert.assertEquals(1, roleGuaranteeService.find(guaranteeFilter, null).getTotalElements());
    Assert.assertEquals(1, roleGuaranteeRoleService.find(guaranteeRoleFilter, null).getTotalElements());
    Assert.assertEquals(1, roleGuaranteeRoleService.find(guaranteeRoleFilter, null).getTotalElements());
    roleService.delete(role);
    // 
    // after delete
    Assert.assertNull(roleService.getByCode(role.getCode()));
    Assert.assertEquals(0, roleGuaranteeService.find(guaranteeFilter, null).getTotalElements());
    Assert.assertEquals(0, roleGuaranteeRoleService.find(guaranteeRoleFilter, null).getTotalElements());
    Assert.assertEquals(0, roleGuaranteeRoleService.find(guaranteeRoleFilter, null).getTotalElements());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter) IdmRoleGuaranteeRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeRoleDto) IdmRoleGuaranteeRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeRoleFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest) Test(org.junit.Test)

Aggregations

IdmRoleGuaranteeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter)12 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)6 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)6 Test (org.junit.Test)6 IdmRoleGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto)5 UUID (java.util.UUID)4 IdmRoleGuaranteeRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeRoleFilter)3 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)3 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)2 IdmEntityStateDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto)2 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)2 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)2 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)1 ConceptRoleRequestOperation (eu.bcvsolutions.idm.core.api.domain.ConceptRoleRequestOperation)1 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)1 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)1 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)1 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)1