use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class JpaQueryParamsEndToEndTest method testDelete.
@Test
public void testDelete() {
TestEntity test = new TestEntity();
test.setId(1L);
test.setStringValue("test");
testRepo.create(test);
testRepo.delete(1L);
List<TestEntity> list = testRepo.findAll(new QueryParams());
Assert.assertEquals(0, list.size());
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class DefaultQuerySpecConverterTest method testFilterNEQ.
@Test
public void testFilterNEQ() throws InstantiationException, IllegalAccessException {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "filter[tasks][id][NEQ]", "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.NEQ, 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 testPaging.
@Test
public void testPaging() throws InstantiationException, IllegalAccessException {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "page[offset]", "1");
addParams(params, "page[limit]", "2");
addParams(params, "sort[tasks][id]", "asc");
QueryParams queryParams = queryParamsBuilder.buildQueryParams(params);
QuerySpec spec = querySpecConverter.fromParams(Task.class, queryParams);
Assert.assertEquals(1L, spec.getOffset());
Assert.assertEquals(Long.valueOf(2L), spec.getLimit());
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class DefaultQuerySpecConverterTest method testIncludeField.
@Test
public void testIncludeField() throws InstantiationException, IllegalAccessException {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "fields[tasks]", "name");
QueryParams queryParams = queryParamsBuilder.buildQueryParams(params);
QuerySpec spec = querySpecConverter.fromParams(Task.class, queryParams);
List<IncludeFieldSpec> includes = spec.getIncludedFields();
Assert.assertEquals(1, includes.size());
IncludeFieldSpec include = includes.get(0);
Assert.assertEquals(Arrays.asList("name"), include.getAttributePath());
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class DefaultQuerySpecConverterTest method testFilterString.
@Test
public void testFilterString() throws InstantiationException, IllegalAccessException {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "filter[tasks][name]", "test1");
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("test1", filter.getValue());
}
Aggregations