use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class AnnotatedResourceRepositoryAdapterTest method setUp.
@Before
public void setUp() throws Exception {
queryParams = new QueryParams();
queryAdapter = new QueryParamsAdapter(queryParams);
parameterProvider = new ParametersFactory(new NewInstanceRepositoryMethodParameterProvider());
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class RepositoryRequestSpecImpl method getQuerySpec.
@Override
public QuerySpec getQuerySpec(ResourceInformation targetResourceInformation) {
if (queryAdapter instanceof QuerySpecAdapter) {
QuerySpec querySpec = ((QuerySpecAdapter) queryAdapter).getQuerySpec();
return querySpec.getOrCreateQuerySpec(targetResourceInformation);
}
Class<?> targetResourceClass = targetResourceInformation.getResourceClass();
QueryParams queryParams = getQueryParams();
DefaultQuerySpecConverter converter = new DefaultQuerySpecConverter(moduleRegistry);
return converter.fromParams(targetResourceClass, queryParams);
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class JpaQueryParamsEndToEndTest method includeOneRelatedValueParams.
private QueryParams includeOneRelatedValueParams() {
Map<String, Set<String>> params = new HashMap<String, Set<String>>();
addParams(params, "include[test]", TestEntity.ATTR_oneRelatedValue);
QueryParams queryParams = queryParamsBuilder.buildQueryParams(params);
return queryParams;
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class JpaQueryParamsEndToEndTest method testIncludeNoRelations.
@Test
public void testIncludeNoRelations() throws InstantiationException, IllegalAccessException {
addTestWithOneRelation();
List<TestEntity> list = testRepo.findAll(new QueryParams());
Assert.assertEquals(1, list.size());
for (TestEntity test : list) {
// in the future we may get proxies here
Assert.assertNull(test.getOneRelatedValue());
}
}
use of io.crnk.legacy.queryParams.QueryParams in project crnk-framework by crnk-project.
the class JpaQueryParamsEndToEndTest method testSaveAndFind.
@Test
public void testSaveAndFind() {
TestEntity task = new TestEntity();
task.setId(1L);
task.setStringValue("test");
testRepo.create(task);
// check retrievable with findAll
List<TestEntity> list = testRepo.findAll(new QueryParams());
Assert.assertEquals(1, list.size());
TestEntity savedTask = list.get(0);
Assert.assertEquals(task.getId(), savedTask.getId());
Assert.assertEquals(task.getStringValue(), savedTask.getStringValue());
// check retrievable with findAll(ids)
list = testRepo.findAll(Arrays.asList(1L), new QueryParams());
Assert.assertEquals(1, list.size());
savedTask = list.get(0);
Assert.assertEquals(task.getId(), savedTask.getId());
Assert.assertEquals(task.getStringValue(), savedTask.getStringValue());
// check retrievable with findOne
savedTask = testRepo.findOne(1L, new QueryParams());
Assert.assertEquals(task.getId(), savedTask.getId());
Assert.assertEquals(task.getStringValue(), savedTask.getStringValue());
}
Aggregations