use of org.entando.entando.web.common.model.RestListRequest in project entando-core by entando.
the class RestListRequestTest method should_exclude_pagination_when_pagesize_0.
@Test
public void should_exclude_pagination_when_pagesize_0() {
RestListRequest request = new RestListRequest();
request.setPage(1);
request.setPageSize(0);
request.setSort("name");
request.setDirection(FieldSearchFilter.Order.ASC.name());
request.addFilter(new Filter("name", "jack"));
request.addFilter(new Filter("city", "rome"));
request.addFilter(new Filter("mobile", "+39"));
// filters
List<FieldSearchFilter> filters = request.buildFieldSearchFilters();
assertThat(filters.size(), is(4));
assertThat(filters.get(0).getKey(), is("name"));
assertThat(filters.get(1).getKey(), is("city"));
assertThat(filters.get(2).getKey(), is("mobile"));
// sort
assertThat(filters.get(3).getKey(), is("name"));
assertThat(filters.get(3).getOrder(), is(FieldSearchFilter.Order.ASC));
}
use of org.entando.entando.web.common.model.RestListRequest in project entando-core by entando.
the class RestListRequestTest method shuold_create_filters.
@Test
public void shuold_create_filters() {
RestListRequest request = new RestListRequest();
request.setPage(1);
request.setPageSize(25);
request.setSort("name");
request.setDirection(FieldSearchFilter.Order.ASC.name());
request.addFilter(new Filter("name", "jack"));
request.addFilter(new Filter("city", "rome"));
request.addFilter(new Filter("mobile", "+39"));
// filters
List<FieldSearchFilter> filters = request.buildFieldSearchFilters();
assertThat(filters.size(), is(5));
assertThat(filters.get(0).getKey(), is("name"));
assertThat(filters.get(1).getKey(), is("city"));
assertThat(filters.get(2).getKey(), is("mobile"));
// pagination
assertThat(filters.get(3).getKey(), is(nullValue()));
assertThat(filters.get(3).getLimit(), is(not(nullValue())));
assertThat(filters.get(3).getOffset(), is(not(nullValue())));
// sort
assertThat(filters.get(4).getKey(), is("name"));
assertThat(filters.get(4).getOrder(), is(FieldSearchFilter.Order.ASC));
}
use of org.entando.entando.web.common.model.RestListRequest in project entando-core by entando.
the class RestListRequestTest method should_default_direction.
@Test
public void should_default_direction() {
RestListRequest request = new RestListRequest();
request.setPage(1);
request.setPageSize(0);
request.setSort("name");
request.setDirection("wrong");
// filters
List<FieldSearchFilter> filters = request.buildFieldSearchFilters();
assertThat(filters.size(), is(1));
assertThat(filters.get(0).getOrder(), is(FieldSearchFilter.Order.ASC));
}
use of org.entando.entando.web.common.model.RestListRequest in project entando-core by entando.
the class TestPageModelManager method testSearch_with_page_filter.
public void testSearch_with_page_filter() throws ApsSystemException {
RestListRequest restListRequest = new RestListRequest();
restListRequest.setPageSize(2);
restListRequest.setPage(1);
List<FieldSearchFilter> filters = restListRequest.buildFieldSearchFilters();
SearcherDaoPaginatedResult<PageModel> result = this._pageModelManager.searchPageModels(filters);
assertThat(result.getCount(), is(3));
assertThat(result.getList().size(), is(2));
restListRequest.addFilter(new Filter("descr", "modello"));
result = this._pageModelManager.searchPageModels(restListRequest.buildFieldSearchFilters());
assertThat(result.getCount(), is(2));
assertThat(result.getList().size(), is(2));
restListRequest.setPage(0);
result = this._pageModelManager.searchPageModels(restListRequest.buildFieldSearchFilters());
assertThat(result.getCount(), is(2));
assertThat(result.getList().size(), is(2));
}
use of org.entando.entando.web.common.model.RestListRequest in project entando-core by entando.
the class DataObjectModelControllerTest method should_load_the_list_of_dataModels.
@SuppressWarnings("unchecked")
@Test
public void should_load_the_list_of_dataModels() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
when(dataObjectModelService.getDataObjectModels(any(RestListRequest.class))).thenReturn(new PagedMetadata<DataModelDto>());
ResultActions result = mockMvc.perform(get("/dataModels").param("page", "1").param("pageSize", "4").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
RestListRequest restListReq = new RestListRequest();
restListReq.setPage(1);
restListReq.setPageSize(4);
Mockito.verify(dataObjectModelService, Mockito.times(1)).getDataObjectModels(restListReq);
}
Aggregations