Search in sources :

Example 6 with IdmRoleCatalogueDto

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);
    }
}
Also used : IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest)

Example 7 with IdmRoleCatalogueDto

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);
}
Also used : IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest)

Example 8 with IdmRoleCatalogueDto

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());
}
Also used : IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) IdmRoleCatalogueFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCatalogueFilter) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 9 with IdmRoleCatalogueDto

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());
}
Also used : IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) IdmRoleCatalogueFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCatalogueFilter) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 10 with IdmRoleCatalogueDto

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());
}
Also used : IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) IdmRoleCatalogueFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCatalogueFilter) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

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