use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class DefaultQuerySpecConverterTest method testNestedObjectFilter.
@Test
public void testNestedObjectFilter() throws InstantiationException, IllegalAccessException {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "filter[projects][data][data]", "myData");
QueryParams queryParams = queryParamsBuilder.buildQueryParams(params);
QuerySpec spec = querySpecConverter.fromParams(Project.class, queryParams);
List<FilterSpec> filters = spec.getFilters();
Assert.assertEquals(1, filters.size());
FilterSpec filter = filters.get(0);
Assert.assertEquals(Arrays.asList("data", "data"), filter.getAttributePath());
Assert.assertEquals(FilterOperator.EQ, filter.getOperator());
Assert.assertEquals("myData", filter.getValue());
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class DefaultQuerySpecConverterTest method testFilterLike.
@Test
public void testFilterLike() throws InstantiationException, IllegalAccessException {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "filter[tasks][name][GE]", "myTask");
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("name"), filter.getAttributePath());
Assert.assertEquals(FilterOperator.GE, filter.getOperator());
Assert.assertEquals("myTask", filter.getValue());
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class DefaultQuerySpecConverterTest method testNestedRelationFilter.
@Test
public void testNestedRelationFilter() throws InstantiationException, IllegalAccessException {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "filter[tasks][project][name]", "myProject");
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("project", "name"), filter.getAttributePath());
Assert.assertEquals(FilterOperator.EQ, filter.getOperator());
Assert.assertEquals("myProject", filter.getValue());
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class DefaultQuerySpecConverterTest method testIncludeRelations.
@Test
public void testIncludeRelations() throws InstantiationException, IllegalAccessException {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "include[tasks]", "project");
QueryParams queryParams = queryParamsBuilder.buildQueryParams(params);
QuerySpec spec = querySpecConverter.fromParams(Task.class, queryParams);
List<IncludeRelationSpec> includes = spec.getIncludedRelations();
Assert.assertEquals(1, includes.size());
IncludeRelationSpec include = includes.get(0);
Assert.assertEquals(Arrays.asList("project"), include.getAttributePath());
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class QuerySpecRepositoryTest method testCrudWithQueryParamsInput.
@Test
public void testCrudWithQueryParamsInput() {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "sort[tasks][name]", "asc");
QueryParams queryParams = queryParamsBuilder.buildQueryParams(params);
QueryParamsAdapter queryAdapter = new QueryParamsAdapter(resourceRegistry.getEntry(Task.class).getResourceInformation(), queryParams, moduleRegistry);
checkCrud(queryAdapter);
}
Aggregations