use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto in project CzechIdMng by bcvsolutions.
the class IdmRoleCatalogueControllerTest method testRoleCatalogueRootsSort.
@Test
public void testRoleCatalogueRootsSort() throws Exception {
testHelper.createRoleCatalogue("ccc");
testHelper.createRoleCatalogue("cc");
testHelper.createRoleCatalogue("c");
testHelper.createRoleCatalogue("aaa");
testHelper.createRoleCatalogue("aa");
testHelper.createRoleCatalogue("a");
testHelper.createRoleCatalogue("bbb");
testHelper.createRoleCatalogue("bb");
testHelper.createRoleCatalogue("b");
testHelper.createRoleCatalogue("abc");
getMockMvc().perform(get(BaseController.BASE_PATH + "/role-catalogues/search/roots?size=10&page=0&sort=name,asc").with(authentication(getAuthentication())).contentType(InitTestData.HAL_CONTENT_TYPE)).andExpect(status().isOk()).andExpect(content().contentType(InitTestData.HAL_CONTENT_TYPE));
String jsonString = this.getJsonAsString("/role-catalogues/search/roots", null, 20l, 0l, "name", "asc", getAuthentication());
List<LinkedHashMap<String, Object>> catalogues = this.getEmbeddedList("roleCatalogues", jsonString);
assertEquals(10, catalogues.size());
assertEquals("a", catalogues.get(0).get(IdmRoleCatalogue_.name.getName()));
assertEquals("ccc", catalogues.get(9).get(IdmRoleCatalogue_.name.getName()));
jsonString = this.getJsonAsString("/role-catalogues/search/roots", null, 20l, 0l, "name", "desc", getAuthentication());
catalogues = this.getEmbeddedList("roleCatalogues", jsonString);
assertEquals(10, catalogues.size());
assertEquals("ccc", catalogues.get(0).get(IdmRoleCatalogue_.name.getName()));
assertEquals("a", catalogues.get(9).get(IdmRoleCatalogue_.name.getName()));
// clear data
for (IdmRoleCatalogueDto dto : roleCatalogueService.find(null).getContent()) {
roleCatalogueService.delete(dto);
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto in project CzechIdMng by bcvsolutions.
the class IdmRoleCatalogueControllerTest method testRoleCatalogueChildren.
@Test
public void testRoleCatalogueChildren() throws Exception {
IdmRoleCatalogueDto root = testHelper.createRoleCatalogue("root");
testHelper.createRoleCatalogue("ccc", root.getId());
testHelper.createRoleCatalogue("cc", root.getId());
testHelper.createRoleCatalogue("c", root.getId());
testHelper.createRoleCatalogue("aaa", root.getId());
testHelper.createRoleCatalogue("aa", root.getId());
testHelper.createRoleCatalogue("a", root.getId());
testHelper.createRoleCatalogue("bbb", root.getId());
testHelper.createRoleCatalogue("bb", root.getId());
testHelper.createRoleCatalogue("b", root.getId());
testHelper.createRoleCatalogue("abc", root.getId());
getMockMvc().perform(get(BaseController.BASE_PATH + "/role-catalogues/search/children?parent=" + root.getId() + "&size=10&page=0&sort=name,asc").with(authentication(getAuthentication())).contentType(InitTestData.HAL_CONTENT_TYPE)).andExpect(status().isOk()).andExpect(content().contentType(InitTestData.HAL_CONTENT_TYPE));
String jsonString = this.getJsonAsString("/role-catalogues/search/children", "parent=" + root.getId(), 20l, 0l, "name", "asc", getAuthentication());
List<LinkedHashMap<String, Object>> catalogues = this.getEmbeddedList("roleCatalogues", jsonString);
assertEquals(10, catalogues.size());
assertEquals("a", catalogues.get(0).get(IdmRoleCatalogue_.name.getName()));
assertEquals("ccc", catalogues.get(9).get(IdmRoleCatalogue_.name.getName()));
jsonString = this.getJsonAsString("/role-catalogues/search/children", "parent=" + root.getId(), 20l, 0l, "name", "desc", getAuthentication());
catalogues = this.getEmbeddedList("roleCatalogues", jsonString);
assertEquals(10, catalogues.size());
assertEquals("ccc", catalogues.get(0).get(IdmRoleCatalogue_.name.getName()));
assertEquals("a", catalogues.get(9).get(IdmRoleCatalogue_.name.getName()));
// clear data
for (IdmRoleCatalogueDto dto : roleCatalogueService.findChildrenByParent(root.getId(), null).getContent()) {
roleCatalogueService.delete(dto);
}
roleCatalogueService.delete(root);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleCatalogueServiceIntegrationTest method textFilterTest.
@Test
public void textFilterTest() {
IdmRoleCatalogueDto catalogue = helper.createRoleCatalogue();
catalogue.setCode("NameCat001");
roleCatalogueService.save(catalogue);
IdmRoleCatalogueDto catalogue2 = helper.createRoleCatalogue();
catalogue2.setCode("NameCat002");
roleCatalogueService.save(catalogue2);
IdmRoleCatalogueDto catalogue3 = helper.createRoleCatalogue();
catalogue3.setCode("NameCat103");
roleCatalogueService.save(catalogue3);
IdmRoleCatalogueDto catalogue4 = helper.createRoleCatalogue();
catalogue4.setName("NameCat004");
roleCatalogueService.save(catalogue4);
IdmRoleCatalogueFilter filter = new IdmRoleCatalogueFilter();
filter.setText("NameCat00");
Page<IdmRoleCatalogueDto> result = roleCatalogueService.find(filter, null);
assertEquals("Wrong text filter count", 3, result.getTotalElements());
assertEquals("Wrong text by Id", catalogue.getId(), result.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleCatalogueServiceIntegrationTest method nameFilterTest.
@Test
public void nameFilterTest() {
IdmRoleCatalogueDto catalogue = helper.createRoleCatalogue();
IdmRoleCatalogueDto catalogue2 = helper.createRoleCatalogue();
IdmRoleCatalogueDto catalogue3 = helper.createRoleCatalogue();
IdmRoleCatalogueFilter filter = new IdmRoleCatalogueFilter();
filter.setName(catalogue.getName());
Page<IdmRoleCatalogueDto> result = roleCatalogueService.find(filter, null);
assertEquals("Wrong name count", 1, result.getTotalElements());
assertEquals("Wrong name", catalogue.getId(), result.getContent().get(0).getId());
filter.setName(catalogue2.getName());
result = roleCatalogueService.find(filter, null);
assertEquals("Wrong name 2 count", 1, result.getTotalElements());
assertEquals("Wrong name", catalogue2.getId(), result.getContent().get(0).getId());
filter.setName(catalogue3.getName());
result = roleCatalogueService.find(filter, null);
assertEquals("Wrong name 3 count", 1, result.getTotalElements());
assertEquals("Wrong name", catalogue3.getId(), result.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleCatalogueServiceIntegrationTest method codeFilterTest.
@Test
public void codeFilterTest() {
IdmRoleCatalogueDto catalogue = helper.createRoleCatalogue();
IdmRoleCatalogueDto catalogue2 = helper.createRoleCatalogue();
IdmRoleCatalogueDto catalogue3 = helper.createRoleCatalogue();
IdmRoleCatalogueFilter filter = new IdmRoleCatalogueFilter();
filter.setCode(catalogue.getCode());
Page<IdmRoleCatalogueDto> result = roleCatalogueService.find(filter, null);
assertEquals("Wrong code count", 1, result.getTotalElements());
assertEquals("Wrong code", catalogue.getId(), result.getContent().get(0).getId());
filter.setCode(catalogue2.getCode());
result = roleCatalogueService.find(filter, null);
assertEquals("Wrong code 2 count", 1, result.getTotalElements());
assertEquals("Wrong code 2", catalogue2.getId(), result.getContent().get(0).getId());
filter.setCode(catalogue3.getCode());
result = roleCatalogueService.find(filter, null);
assertEquals("Wrong code 3 count", 1, result.getTotalElements());
assertEquals("Wrong code 3", catalogue3.getId(), result.getContent().get(0).getId());
}
Aggregations