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);
}
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());
}
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());
}
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);
}
Aggregations