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());
}
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));
}
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);
}
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);
}
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);
}
Aggregations