use of org.entando.entando.web.common.model.Filter 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.Filter in project entando-core by entando.
the class PagedMetadataTest method lastPage.
@Test
public void lastPage() {
RestListRequest request = new RestListRequest();
request.setPage(1);
request.setPageSize(25);
request.setSort("outerCode");
request.setDirection(FieldSearchFilter.Order.ASC.name());
request.addFilter(new Filter("outerCode", "code"));
List<Outer> list = createList();
PagedMetadata<Outer> result = new PagedMetadata<>(request, list, list.size());
assertThat(result.getBody().size(), is(10));
assertThat(result.getPage(), is(1));
assertThat(result.getTotalItems(), is(10));
assertThat(result.getLastPage(), is(1));
}
use of org.entando.entando.web.common.model.Filter in project entando-core by entando.
the class PagedMetadataTest method lastPage2.
@Test
public void lastPage2() {
RestListRequest request = new RestListRequest();
request.setPage(1);
request.setPageSize(25);
request.setSort("outerCode");
request.setDirection(FieldSearchFilter.Order.ASC.name());
request.addFilter(new Filter("outerCode", "code"));
List<Outer> list = new ArrayList<>();
PagedMetadata<Outer> result = new PagedMetadata<>(request, list, list.size());
assertThat(result.getBody().size(), is(0));
assertThat(result.getPage(), is(1));
assertThat(result.getTotalItems(), is(0));
assertThat(result.getLastPage(), is(1));
}
Aggregations