Search in sources :

Example 31 with FilterSpec

use of io.crnk.core.queryspec.FilterSpec in project crnk-framework by crnk-project.

the class RestTemplateClientTest method testFindEmpty.

@Test
public void testFindEmpty() {
    QuerySpec querySpec = new QuerySpec(Task.class);
    querySpec.addFilter(new FilterSpec(Arrays.asList("name"), FilterOperator.EQ, "doesNotExist"));
    List<Task> tasks = taskRepo.findAll(querySpec);
    Assert.assertTrue(tasks.isEmpty());
}
Also used : Task(io.crnk.test.mock.models.Task) QuerySpec(io.crnk.core.queryspec.QuerySpec) FilterSpec(io.crnk.core.queryspec.FilterSpec) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 32 with FilterSpec

use of io.crnk.core.queryspec.FilterSpec in project crnk-framework by crnk-project.

the class RegistryEntryFacadeTest method checkFindAllWithFilter.

@Test
public void checkFindAllWithFilter() {
    QuerySpec querySpec = new QuerySpec(User.class);
    querySpec.addFilter(new FilterSpec(Arrays.asList("id"), FilterOperator.EQ, user2.getId()));
    ResourceList<User> list = facade.findAll(querySpec);
    Assert.assertEquals(1, list.size());
    Assert.assertSame(user2, list.get(0));
}
Also used : User(io.crnk.core.mock.models.User) QuerySpec(io.crnk.core.queryspec.QuerySpec) FilterSpec(io.crnk.core.queryspec.FilterSpec) Test(org.junit.Test)

Example 33 with FilterSpec

use of io.crnk.core.queryspec.FilterSpec in project crnk-framework by crnk-project.

the class DefaultQuerySpecDeserializerTestBase method testFilterEquals.

@Test
public void testFilterEquals() {
    QuerySpec expectedSpec = new QuerySpec(Task.class);
    expectedSpec.addFilter(new FilterSpec(Arrays.asList("id"), FilterOperator.EQ, 1L));
    Map<String, Set<String>> params = new HashMap<>();
    add(params, "filter[tasks][id][EQ]", "1");
    QuerySpec actualSpec = deserializer.deserialize(taskInformation, params);
    Assert.assertEquals(expectedSpec, actualSpec);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) QuerySpec(io.crnk.core.queryspec.QuerySpec) FilterSpec(io.crnk.core.queryspec.FilterSpec) AbstractQuerySpecTest(io.crnk.core.queryspec.AbstractQuerySpecTest) Test(org.junit.Test)

Example 34 with FilterSpec

use of io.crnk.core.queryspec.FilterSpec in project crnk-framework by crnk-project.

the class DefaultQuerySpecDeserializerTestBase method testFilterWithDotNotationMultipleElements.

@Test
public void testFilterWithDotNotationMultipleElements() {
    QuerySpec expectedSpec = new QuerySpec(Task.class);
    expectedSpec.addFilter(new FilterSpec(Arrays.asList("project", "task", "name"), FilterOperator.EQ, "value"));
    Map<String, Set<String>> params = new HashMap<>();
    add(params, "filter[project.task.name]", "value");
    QuerySpec actualSpec = deserializer.deserialize(taskInformation, params);
    Assert.assertEquals(expectedSpec, actualSpec);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) QuerySpec(io.crnk.core.queryspec.QuerySpec) FilterSpec(io.crnk.core.queryspec.FilterSpec) AbstractQuerySpecTest(io.crnk.core.queryspec.AbstractQuerySpecTest) Test(org.junit.Test)

Example 35 with FilterSpec

use of io.crnk.core.queryspec.FilterSpec in project crnk-framework by crnk-project.

the class DefaultQuerySpecDeserializerTestBase method testFilterGreater.

@Test
public void testFilterGreater() {
    QuerySpec expectedSpec = new QuerySpec(Task.class);
    expectedSpec.addFilter(new FilterSpec(Arrays.asList("id"), FilterOperator.LE, 1L));
    Map<String, Set<String>> params = new HashMap<>();
    add(params, "filter[tasks][id][LE]", "1");
    QuerySpec actualSpec = deserializer.deserialize(taskInformation, params);
    Assert.assertEquals(expectedSpec, actualSpec);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) QuerySpec(io.crnk.core.queryspec.QuerySpec) FilterSpec(io.crnk.core.queryspec.FilterSpec) AbstractQuerySpecTest(io.crnk.core.queryspec.AbstractQuerySpecTest) Test(org.junit.Test)

Aggregations

FilterSpec (io.crnk.core.queryspec.FilterSpec)56 QuerySpec (io.crnk.core.queryspec.QuerySpec)51 Test (org.junit.Test)40 HashSet (java.util.HashSet)14 Set (java.util.Set)13 AbstractQuerySpecTest (io.crnk.core.queryspec.AbstractQuerySpecTest)12 HashMap (java.util.HashMap)12 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)9 TaskResource (io.crnk.activiti.resource.TaskResource)8 MetaResource (io.crnk.meta.model.resource.MetaResource)8 ScheduleApprovalProcessInstance (io.crnk.activiti.example.model.ScheduleApprovalProcessInstance)5 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)5 MetaAttribute (io.crnk.meta.model.MetaAttribute)5 ResourceField (io.crnk.core.engine.information.resource.ResourceField)4 ResourceList (io.crnk.core.resource.list.ResourceList)3 RelatedEntity (io.crnk.jpa.model.RelatedEntity)3 ArrayList (java.util.ArrayList)3 MultivaluedMap (io.crnk.core.engine.internal.utils.MultivaluedMap)2 ResourceRepositoryV2 (io.crnk.core.repository.ResourceRepositoryV2)2 JsonApiResponse (io.crnk.core.repository.response.JsonApiResponse)2