Search in sources :

Example 26 with QueryParams

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());
}
Also used : NewInstanceRepositoryMethodParameterProvider(io.crnk.core.engine.repository.mock.NewInstanceRepositoryMethodParameterProvider) ParametersFactory(io.crnk.legacy.internal.ParametersFactory) QueryParams(io.crnk.legacy.queryParams.QueryParams) QueryParamsAdapter(io.crnk.legacy.internal.QueryParamsAdapter) Before(org.junit.Before)

Example 27 with QueryParams

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);
}
Also used : QueryParams(io.crnk.legacy.queryParams.QueryParams) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter) QuerySpec(io.crnk.core.queryspec.QuerySpec) DefaultQuerySpecConverter(io.crnk.legacy.internal.DefaultQuerySpecConverter)

Example 28 with 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;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) QueryParams(io.crnk.legacy.queryParams.QueryParams)

Example 29 with 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());
    }
}
Also used : TestEntity(io.crnk.jpa.model.TestEntity) QueryParams(io.crnk.legacy.queryParams.QueryParams) Test(org.junit.Test) AbstractJpaJerseyTest(io.crnk.jpa.AbstractJpaJerseyTest)

Example 30 with QueryParams

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());
}
Also used : TestEntity(io.crnk.jpa.model.TestEntity) QueryParams(io.crnk.legacy.queryParams.QueryParams) Test(org.junit.Test) AbstractJpaJerseyTest(io.crnk.jpa.AbstractJpaJerseyTest)

Aggregations

QueryParams (io.crnk.legacy.queryParams.QueryParams)46 Test (org.junit.Test)37 QueryParamsAdapter (io.crnk.legacy.internal.QueryParamsAdapter)10 Response (io.crnk.core.engine.dispatcher.Response)9 JsonPath (io.crnk.core.engine.internal.dispatcher.path.JsonPath)9 Document (io.crnk.core.engine.document.Document)7 BaseControllerTest (io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest)7 Project (io.crnk.core.mock.models.Project)7 AbstractJpaJerseyTest (io.crnk.jpa.AbstractJpaJerseyTest)7 Resource (io.crnk.core.engine.document.Resource)6 TaskToProjectRepository (io.crnk.core.mock.repository.TaskToProjectRepository)6 TestEntity (io.crnk.jpa.model.TestEntity)6 Task (io.crnk.test.mock.models.Task)6 ResourcePost (io.crnk.core.engine.internal.dispatcher.controller.ResourcePost)5 Task (io.crnk.core.mock.models.Task)5 DefaultQueryParamsParser (io.crnk.legacy.queryParams.DefaultQueryParamsParser)5 QueryParamsBuilder (io.crnk.legacy.queryParams.QueryParamsBuilder)5 Relationship (io.crnk.core.engine.document.Relationship)3 ResourceIdentifier (io.crnk.core.engine.document.ResourceIdentifier)3 ResourceModificationFilter (io.crnk.core.engine.filter.ResourceModificationFilter)3