Search in sources :

Example 36 with Filter

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));
}
Also used : FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) Filter(org.entando.entando.web.common.model.Filter) RestListRequest(org.entando.entando.web.common.model.RestListRequest) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) AbstractControllerTest(org.entando.entando.web.AbstractControllerTest) Test(org.junit.Test)

Example 37 with Filter

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));
}
Also used : FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) Filter(org.entando.entando.web.common.model.Filter) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) RestListRequest(org.entando.entando.web.common.model.RestListRequest) Test(org.junit.Test)

Example 38 with Filter

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));
}
Also used : FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) Filter(org.entando.entando.web.common.model.Filter) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) RestListRequest(org.entando.entando.web.common.model.RestListRequest) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

Filter (org.entando.entando.web.common.model.Filter)38 RestListRequest (org.entando.entando.web.common.model.RestListRequest)30 Test (org.junit.Test)26 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)16 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)9 AbstractControllerTest (org.entando.entando.web.AbstractControllerTest)8 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)5 UserDetails (com.agiletec.aps.system.services.user.UserDetails)4 ResultActions (org.springframework.test.web.servlet.ResultActions)4 Permission (com.agiletec.aps.system.services.role.Permission)3 Role (com.agiletec.aps.system.services.role.Role)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)3 RestServerError (org.entando.entando.aps.system.exception.RestServerError)3 GroupDto (org.entando.entando.aps.system.services.group.model.GroupDto)3 LabelDto (org.entando.entando.aps.system.services.label.model.LabelDto)3 RoleDto (org.entando.entando.aps.system.services.role.model.RoleDto)3 WidgetDto (org.entando.entando.aps.system.services.widgettype.model.WidgetDto)3 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)3