use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleGuaranteeServiceIntegrationTest method testFindRoleGuaranteeByRole.
@Test
public void testFindRoleGuaranteeByRole() {
IdmIdentityDto guarantee1 = testHelper.createIdentity();
IdmIdentityDto guarantee2 = testHelper.createIdentity();
IdmIdentityDto guarantee3 = testHelper.createIdentity();
//
IdmRoleDto role = testHelper.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();
assertEquals(3, list.size());
//
List<UUID> guarantees = list.stream().map(IdmRoleGuaranteeDto::getGuarantee).collect(Collectors.toList());
roleGuarantee = list.get(0);
assertEquals(role.getId(), roleGuarantee.getRole());
assertTrue(guarantees.contains(guarantee3.getId()));
assertTrue(guarantees.contains(guarantee2.getId()));
assertTrue(guarantees.contains(guarantee1.getId()));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleGuaranteeServiceIntegrationTest method testFindRoleGuaranteeByGuarantee.
@Test
public void testFindRoleGuaranteeByGuarantee() {
IdmIdentityDto guarantee = testHelper.createIdentity();
//
IdmRoleDto role1 = testHelper.createRole();
IdmRoleDto role2 = testHelper.createRole();
IdmRoleDto role3 = testHelper.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();
assertEquals(3, list.size());
//
List<UUID> roles = list.stream().map(IdmRoleGuaranteeDto::getRole).collect(Collectors.toList());
roleGuarantee = list.get(0);
assertEquals(guarantee.getId(), roleGuarantee.getGuarantee());
assertTrue(roles.contains(role1.getId()));
assertTrue(roles.contains(role2.getId()));
assertTrue(roles.contains(role3.getId()));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto 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));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleServiceIntegrationTest method testReferentialIntegrity.
@Test
public void testReferentialIntegrity() {
IdmIdentityDto identity = new IdmIdentityDto();
String username = "delete_test_" + System.currentTimeMillis();
identity.setUsername(username);
// confidential storage
identity.setPassword(new GuardedString("heslo"));
identity.setFirstName("Test");
identity.setLastName("Identity");
identity = identityService.save(identity);
// role
IdmRoleDto role = new IdmRoleDto();
String roleName = "test_r_" + System.currentTimeMillis();
role.setName(roleName);
IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role.getId());
roleGuarantee.setGuarantee(identity.getId());
role.setGuarantees(Lists.newArrayList(roleGuarantee));
role = roleService.save(role);
assertNotNull(roleService.getByCode(roleName));
assertEquals(1, roleGuaranteeRepository.findAllByRole_Id(role.getId()).size());
roleService.delete(role);
assertNull(roleService.getByCode(roleName));
assertEquals(0, roleGuaranteeRepository.findAllByRole_Id(role.getId()).size());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleServiceIntegrationTest method typeFilterTest.
@Test
public void typeFilterTest() {
IdmRoleDto role = helper.createRole();
IdmRoleDto role2 = helper.createRole();
IdmRoleDto role3 = helper.createRole();
RoleType type = RoleType.LOGIN;
RoleType type2 = RoleType.BUSINESS;
role = roleService.get(role.getId());
role.setRoleType(type);
role = roleService.save(role);
role2 = roleService.get(role2.getId());
role2.setRoleType(type);
role2 = roleService.save(role2);
role3 = roleService.get(role3.getId());
role3.setRoleType(type2);
role3 = roleService.save(role3);
IdmRoleFilter filter = new IdmRoleFilter();
filter.setRoleType(type);
Page<IdmRoleDto> result = roleService.find(filter, null);
assertEquals("Wrong type #1", 2, result.getTotalElements());
assertTrue("Wrong type #1 contains", result.getContent().contains(role));
filter.setRoleType(type2);
result = roleService.find(filter, null);
assertEquals("Wrong type #2", 1, result.getTotalElements());
assertTrue("Wrong type #2 contains", result.getContent().contains(role3));
}
Aggregations