Search in sources :

Example 1 with IdmRoleCatalogueRoleDto

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

the class DefaultIdmRoleCatalogueServiceIntegrationTest method testReferentialIntegrity.

@Test
public void testReferentialIntegrity() {
    // catalogue
    IdmRoleCatalogueDto roleCatalogue = new IdmRoleCatalogueDto();
    String catalogueName = "cat_one_" + System.currentTimeMillis();
    roleCatalogue.setCode(catalogueName);
    roleCatalogue.setName(catalogueName);
    roleCatalogue = roleCatalogueService.save(roleCatalogue);
    // role
    IdmRoleDto role = new IdmRoleDto();
    String roleName = "test_r_" + System.currentTimeMillis();
    role.setName(roleName);
    // 
    IdmRoleCatalogueRoleDto roleCatalogueRole = new IdmRoleCatalogueRoleDto();
    roleCatalogueRole.setRole(role.getId());
    roleCatalogueRole.setRoleCatalogue(roleCatalogue.getId());
    // 
    role.setRoleCatalogues(Lists.newArrayList(roleCatalogueRole));
    role = roleService.save(role);
    // 
    List<IdmRoleCatalogueRoleDto> list = role.getRoleCatalogues();
    assertEquals(1, list.size());
    UUID catalogId = list.get(0).getRoleCatalogue();
    UUID roleId = list.get(0).getRole();
    // 
    assertNotNull(catalogId);
    assertNotNull(roleId);
    assertEquals(roleCatalogue.getId(), catalogId);
    assertEquals(role.getId(), roleId);
    // 
    roleCatalogueService.delete(roleCatalogue);
    // 
    List<IdmRoleCatalogueDto> roleCatalogues = roleCatalogueService.findAllByRole(role.getId());
    assertEquals(0, roleCatalogues.size());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCatalogueRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) UUID(java.util.UUID) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 2 with IdmRoleCatalogueRoleDto

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

the class DefaultIdmRoleServiceIntegrationTest method catalogueFilterTest.

@Test
public void catalogueFilterTest() {
    IdmRoleDto role = new IdmRoleDto();
    role.setName("PetrSadloRole");
    role = roleService.save(role);
    IdmRoleCatalogueDto catalogue = helper.createRoleCatalogue();
    IdmRoleCatalogueRoleDto catalogueRole = new IdmRoleCatalogueRoleDto();
    catalogueRole.setRole(role.getId());
    catalogueRole.setRoleCatalogue(catalogue.getId());
    catalogueRole = idmRoleCatalogueRoleService.save(catalogueRole);
    IdmRoleFilter filter = new IdmRoleFilter();
    filter.setRoleCatalogueId(catalogue.getId());
    Page<IdmRoleDto> result = roleService.find(filter, null);
    assertEquals("Wrong catalogue", 1, result.getTotalElements());
    assertTrue("Wrong catalogue id #1", result.getContent().contains(role));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCatalogueRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 3 with IdmRoleCatalogueRoleDto

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

the class DefaultIdentityRoleServiceTest method roleCatalogueTest.

@Test
public void roleCatalogueTest() {
    IdmIdentityDto person = testHelper.createIdentity();
    IdmIdentityDto person2 = testHelper.createIdentity();
    IdmRoleCatalogueDto catalogue = testHelper.createRoleCatalogue();
    IdmRoleCatalogueRoleDto catalogueRole = new IdmRoleCatalogueRoleDto();
    IdmRoleCatalogueRoleDto catalogueRole2 = new IdmRoleCatalogueRoleDto();
    IdmIdentityContractDto contract = testHelper.createIdentityContact(person);
    IdmIdentityContractDto contract2 = testHelper.createIdentityContact(person2);
    IdmRoleDto role = testHelper.createRole();
    IdmRoleDto role2 = testHelper.createRole();
    catalogueRole.setRoleCatalogue(catalogue.getId());
    catalogueRole.setRole(role.getId());
    catalogueRole2.setRoleCatalogue(catalogue.getId());
    catalogueRole2.setRole(role2.getId());
    IdmIdentityRoleDto roleCover = testHelper.createIdentityRole(contract, role);
    IdmIdentityRoleDto roleCover2 = testHelper.createIdentityRole(contract2, role2);
    idmRoleCatalogueRoleService.save(catalogueRole);
    idmRoleCatalogueRoleService.save(catalogueRole2);
    IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
    filter.setRoleCatalogueId(catalogue.getId());
    Page<IdmIdentityRoleDto> result = idmIdentityRoleService.find(filter, null);
    assertEquals("Wrong CatalogueRoleId", roleCover.getId(), result.getContent().get(0).getId());
    assertEquals("Wrong CatalogueRoleId2", roleCover2.getId(), result.getContent().get(1).getId());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCatalogueRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Aggregations

IdmRoleCatalogueDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto)3 IdmRoleCatalogueRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto)3 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)3 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)3 Test (org.junit.Test)3 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)1 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)1 IdmIdentityRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter)1 IdmRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter)1 UUID (java.util.UUID)1