Search in sources :

Example 16 with IdmRoleCatalogueDto

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

the class DefaultRoleCatalogueProvisioningTest method provisioningC_CreateAccounts_correct.

@Test
public void provisioningC_CreateAccounts_correct() {
    IdmRoleCatalogueFilter filter = new IdmRoleCatalogueFilter();
    filter.setName("P1");
    IdmRoleCatalogueDto nodeRoot = treeNodeService.find(filter, null).getContent().get(0);
    Assert.assertNotNull(nodeRoot);
    filter.setName("P12");
    IdmRoleCatalogueDto nodeOne = treeNodeService.find(filter, null).getContent().get(0);
    Assert.assertNotNull(nodeOne);
    // Check state before provisioning
    TestTreeResource one = entityManager.find(TestTreeResource.class, "P12");
    Assert.assertNull(one);
    TestTreeResource root = entityManager.find(TestTreeResource.class, "P1");
    Assert.assertNull(root);
    // Save IDM node again (must invoke provisioning)
    // Root first
    treeNodeService.save(nodeRoot);
    // Node next
    treeNodeService.save(nodeOne);
    // Check state before provisioning
    root = entityManager.find(TestTreeResource.class, "P1");
    Assert.assertNotNull(root);
    one = entityManager.find(TestTreeResource.class, "P12");
    Assert.assertNotNull(one);
}
Also used : TestTreeResource(eu.bcvsolutions.idm.acc.entity.TestTreeResource) IdmRoleCatalogueFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCatalogueFilter) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 17 with IdmRoleCatalogueDto

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

the class DefaultIdmRoleCatalogueServiceIntegrationTest method testNameDiffLevel.

// VS: I turned off this validation ... because in implementation is same name (different code) normal situation
// @Test(expected = ResultCodeException.class)
// public void testDuplicitNamesRoots() {
// IdmRoleCatalogueDto roleCatalogue = new IdmRoleCatalogueDto();
// String name = "cat_one_" + System.currentTimeMillis();
// roleCatalogue.setCode(name);
// roleCatalogue.setName("test");
// //
// this.roleCatalogueService.save(roleCatalogue);
// //
// // create second
// IdmRoleCatalogueDto roleCatalogue2 = new IdmRoleCatalogueDto();
// name = "cat_one_" + System.currentTimeMillis();
// roleCatalogue2.setCode(name);
// roleCatalogue2.setName("test");
// // throws error
// this.roleCatalogueService.save(roleCatalogue2);
// }
// 
// @Test(expected = ResultCodeException.class)
// public void testDuplicitNamesChilds() {
// IdmRoleCatalogueDto root = new IdmRoleCatalogueDto();
// String code = "cat_one_" + System.currentTimeMillis();
// root.setCode(code);
// root.setName("test" + System.currentTimeMillis());
// root = this.roleCatalogueService.save(root);
// //
// IdmRoleCatalogueDto roleCatalogue = new IdmRoleCatalogueDto();
// code = "cat_one_" + System.currentTimeMillis();
// roleCatalogue.setCode(code);
// roleCatalogue.setParent(root.getId());
// roleCatalogue.setName("test");
// //
// roleCatalogue = this.roleCatalogueService.save(roleCatalogue);
// //
// // create second
// IdmRoleCatalogueDto roleCatalogue2 = new IdmRoleCatalogueDto();
// code = "cat_one_" + System.currentTimeMillis();
// roleCatalogue2.setCode(code);
// roleCatalogue2.setParent(root.getId());
// roleCatalogue2.setName("test");
// // throws error
// this.roleCatalogueService.save(roleCatalogue2);
// }
@Test
public void testNameDiffLevel() {
    // code must be unique for all nodes,
    // name must be unique for all children of parent.
    IdmRoleCatalogueDto root = new IdmRoleCatalogueDto();
    String code = "cat_one_" + System.currentTimeMillis();
    root.setName("test_01");
    root.setCode(code);
    root = this.roleCatalogueService.save(root);
    // 
    IdmRoleCatalogueDto child1 = new IdmRoleCatalogueDto();
    code = "cat_one_" + System.currentTimeMillis();
    child1.setName("test_02");
    child1.setParent(root.getId());
    child1.setCode(code);
    child1 = this.roleCatalogueService.save(child1);
    // 
    IdmRoleCatalogueDto child2 = new IdmRoleCatalogueDto();
    code = "cat_one_" + System.currentTimeMillis();
    child2.setName("test_02");
    child2.setParent(child1.getId());
    child2.setCode(code);
    child2 = this.roleCatalogueService.save(child2);
    /* excepted
		 * - root
		 * 		- child1
		 * 				- child2
		 */
    assertEquals(1, this.roleCatalogueService.findChildrenByParent(root.getId(), null).getTotalElements());
    assertEquals(1, this.roleCatalogueService.findChildrenByParent(child1.getId(), null).getTotalElements());
    assertEquals(0, this.roleCatalogueService.findChildrenByParent(child2.getId(), null).getTotalElements());
}
Also used : IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 18 with IdmRoleCatalogueDto

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

the class DefaultIdmRoleCatalogueServiceIntegrationTest method parentFilterTest.

@Test
public void parentFilterTest() {
    IdmRoleCatalogueDto catalogue = helper.createRoleCatalogue();
    IdmRoleCatalogueDto catalogue2 = helper.createRoleCatalogue();
    IdmRoleCatalogueDto catalogue3 = helper.createRoleCatalogue();
    IdmRoleCatalogueDto catalogue4 = helper.createRoleCatalogue();
    IdmRoleCatalogueDto catalogue5 = helper.createRoleCatalogue();
    UUID catalogueId = catalogue.getId();
    catalogue2.setParent(catalogueId);
    roleCatalogueService.save(catalogue2);
    catalogue3.setParent(catalogueId);
    roleCatalogueService.save(catalogue3);
    catalogue5.setParent(catalogue4.getId());
    roleCatalogueService.save(catalogue5);
    IdmRoleCatalogueFilter filter = new IdmRoleCatalogueFilter();
    filter.setParent(catalogueId);
    Page<IdmRoleCatalogueDto> result = roleCatalogueService.find(filter, null);
    assertEquals("Wrong parent count", 2, result.getTotalElements());
    assertEquals("Wrong parent contain", true, result.getContent().contains(catalogue3));
    filter.setParent(catalogue4.getId());
    result = roleCatalogueService.find(filter, null);
    assertEquals("Wrong parent count #2", 1, result.getTotalElements());
    assertEquals("Wrong parent Id", catalogue5.getId(), result.getContent().get(0).getId());
    filter.setParent(catalogue5.getId());
    result = roleCatalogueService.find(filter, null);
    assertEquals("Wrong parent count blank", 0, result.getTotalElements());
}
Also used : IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) IdmRoleCatalogueFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCatalogueFilter) UUID(java.util.UUID) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 19 with IdmRoleCatalogueDto

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

the class DefaultTestHelper method createRoleCatalogue.

@Override
public IdmRoleCatalogueDto createRoleCatalogue(String code, UUID parentId) {
    IdmRoleCatalogueDto roleCatalogue = new IdmRoleCatalogueDto();
    code = code == null ? createName() : code;
    roleCatalogue.setName(code);
    roleCatalogue.setParent(parentId);
    roleCatalogue.setCode(code);
    return idmRoleCatalogueService.save(roleCatalogue);
}
Also used : IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto)

Aggregations

IdmRoleCatalogueDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto)19 Test (org.junit.Test)16 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)14 IdmRoleCatalogueFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCatalogueFilter)9 TestTreeResource (eu.bcvsolutions.idm.acc.entity.TestTreeResource)4 IdmRoleCatalogueRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto)3 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)3 AbstractRestTest (eu.bcvsolutions.idm.test.api.AbstractRestTest)2 LinkedHashMap (java.util.LinkedHashMap)2 UUID (java.util.UUID)2 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 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1 Transactional (org.springframework.transaction.annotation.Transactional)1