use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class DefaultQuerySpecConverterTest method testFindAll.
@Test
public void testFindAll() throws InstantiationException, IllegalAccessException {
QuerySpec spec = querySpecConverter.fromParams(Task.class, new QueryParams());
Assert.assertEquals(new QuerySpec(Task.class), spec);
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class DefaultQuerySpecConverterTest method testFilterLong.
@Test
public void testFilterLong() throws InstantiationException, IllegalAccessException {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "filter[tasks][id]", "12");
QueryParams queryParams = queryParamsBuilder.buildQueryParams(params);
QuerySpec spec = querySpecConverter.fromParams(Task.class, queryParams);
List<FilterSpec> filters = spec.getFilters();
Assert.assertEquals(1, filters.size());
FilterSpec filter = filters.get(0);
Assert.assertEquals(Arrays.asList("id"), filter.getAttributePath());
Assert.assertEquals(FilterOperator.EQ, filter.getOperator());
Assert.assertEquals(Long.valueOf(12L), filter.getValue());
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class DefaultQuerySpecConverterTest method testNestedSort.
@Test
public void testNestedSort() throws InstantiationException, IllegalAccessException {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "sort[tasks][project][name]", "asc");
QueryParams queryParams = queryParamsBuilder.buildQueryParams(params);
QuerySpec spec = querySpecConverter.fromParams(Task.class, queryParams);
List<SortSpec> sorts = spec.getSort();
Assert.assertEquals(1, sorts.size());
SortSpec sort = sorts.get(0);
Assert.assertEquals(Arrays.asList("project", "name"), sort.getAttributePath());
Assert.assertEquals(Direction.ASC, sort.getDirection());
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class DefaultQuerySpecConverterTest method testFindAllOrder.
public void testFindAllOrder(boolean asc) throws InstantiationException, IllegalAccessException {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "sort[tasks][name]", asc ? "asc" : "desc");
QueryParams queryParams = queryParamsBuilder.buildQueryParams(params);
QuerySpec spec = querySpecConverter.fromParams(Task.class, queryParams);
List<SortSpec> sort = spec.getSort();
Assert.assertEquals(1, sort.size());
Assert.assertEquals(Arrays.asList("name"), sort.get(0).getAttributePath());
Assert.assertEquals(asc ? Direction.ASC : Direction.DESC, sort.get(0).getDirection());
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class DefaultQuerySpecConverterTest method testFilterUnknownResource.
@Test(expected = IllegalArgumentException.class)
public void testFilterUnknownResource() throws InstantiationException, IllegalAccessException {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "filter[unknown][id]", "12");
QueryParams queryParams = queryParamsBuilder.buildQueryParams(params);
querySpecConverter.fromParams(Task.class, queryParams);
}
Aggregations