Search in sources :

Example 21 with Query

use of org.molgenis.api.model.Query in project molgenis by molgenis.

the class QueryRsqlVisitorTest method testVisitComparisonNodeLessThan.

@ParameterizedTest
@MethodSource("testVisitComparisonNodeLessThanProvider")
void testVisitComparisonNodeLessThan(String symbol) {
    String selector = "age";
    String argument = "87";
    ComparisonOperator operator = new ComparisonOperator(symbol);
    ComparisonNode node = new ComparisonNode(operator, selector, singletonList(argument));
    Query query = Query.builder().setItem(selector).setOperator(LESS_THAN).setValue(argument).build();
    assertEquals(query, queryRsqlVisitor.visit(node));
}
Also used : ComparisonOperator(cz.jirutka.rsql.parser.ast.ComparisonOperator) ComparisonNode(cz.jirutka.rsql.parser.ast.ComparisonNode) Query(org.molgenis.api.model.Query) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 22 with Query

use of org.molgenis.api.model.Query in project molgenis by molgenis.

the class QueryRsqlVisitorTest method testVisitComparisonNodeIn.

@Test
void testVisitComparisonNodeIn() {
    String selector = "name";
    List<String> arguments = asList("jan", "piet");
    ComparisonOperator operator = new ComparisonOperator("=in=", true);
    ComparisonNode node = new ComparisonNode(operator, selector, arguments);
    Query query = Query.builder().setItem(selector).setOperator(IN).setValue(arguments).build();
    assertEquals(query, queryRsqlVisitor.visit(node));
}
Also used : ComparisonOperator(cz.jirutka.rsql.parser.ast.ComparisonOperator) ComparisonNode(cz.jirutka.rsql.parser.ast.ComparisonNode) Query(org.molgenis.api.model.Query) Test(org.junit.jupiter.api.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 23 with Query

use of org.molgenis.api.model.Query in project molgenis by molgenis.

the class QueryRsqlVisitorTest method testVisitComparisonNodeGreaterThan.

@ParameterizedTest
@MethodSource("testVisitComparisonNodeGreaterThanProvider")
void testVisitComparisonNodeGreaterThan(String symbol) {
    String selector = "age";
    String argument = "87";
    ComparisonOperator operator = new ComparisonOperator(symbol);
    ComparisonNode node = new ComparisonNode(operator, selector, singletonList(argument));
    Query query = Query.builder().setItem(selector).setOperator(GREATER_THAN).setValue(argument).build();
    assertEquals(query, queryRsqlVisitor.visit(node));
}
Also used : ComparisonOperator(cz.jirutka.rsql.parser.ast.ComparisonOperator) ComparisonNode(cz.jirutka.rsql.parser.ast.ComparisonNode) Query(org.molgenis.api.model.Query) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 24 with Query

use of org.molgenis.api.model.Query in project molgenis by molgenis.

the class QueryRsqlVisitorTest method testVisitComparisonNodeEqualsNull.

@Test
void testVisitComparisonNodeEqualsNull() {
    String selector = "name";
    String argument = "";
    ComparisonOperator operator = new ComparisonOperator("==");
    ComparisonNode node = new ComparisonNode(operator, selector, singletonList(argument));
    Query query = Query.builder().setItem(selector).setOperator(EQUALS).setValue(null).build();
    assertEquals(query, queryRsqlVisitor.visit(node));
}
Also used : ComparisonOperator(cz.jirutka.rsql.parser.ast.ComparisonOperator) ComparisonNode(cz.jirutka.rsql.parser.ast.ComparisonNode) Query(org.molgenis.api.model.Query) Test(org.junit.jupiter.api.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 25 with Query

use of org.molgenis.api.model.Query in project molgenis by molgenis.

the class QueryRsqlVisitorTest method testVisitComparisonNodeMatchesAllSelector.

@Test
void testVisitComparisonNodeMatchesAllSelector() {
    String selector = "*";
    String argument = "piet";
    ComparisonOperator operator = new ComparisonOperator("=q=");
    ComparisonNode node = new ComparisonNode(operator, selector, singletonList(argument));
    Query query = Query.builder().setItem(null).setOperator(MATCHES).setValue(argument).build();
    assertEquals(query, queryRsqlVisitor.visit(node));
}
Also used : ComparisonOperator(cz.jirutka.rsql.parser.ast.ComparisonOperator) ComparisonNode(cz.jirutka.rsql.parser.ast.ComparisonNode) Query(org.molgenis.api.model.Query) Test(org.junit.jupiter.api.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Query (org.molgenis.api.model.Query)58 Test (org.junit.jupiter.api.Test)52 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)52 Entity (org.molgenis.data.Entity)27 Attribute (org.molgenis.data.meta.model.Attribute)22 QueryImpl (org.molgenis.data.support.QueryImpl)22 ComparisonNode (cz.jirutka.rsql.parser.ast.ComparisonNode)17 ComparisonOperator (cz.jirutka.rsql.parser.ast.ComparisonOperator)17 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 EntityType (org.molgenis.data.meta.model.EntityType)15 Sort (org.molgenis.api.model.Sort)14 Selection (org.molgenis.api.model.Selection)9 Fetch (org.molgenis.data.Fetch)7 AttributeMetadata (org.molgenis.data.meta.model.AttributeMetadata)5 MethodSource (org.junit.jupiter.params.provider.MethodSource)4 EntitiesResponse (org.molgenis.api.data.v3.model.EntitiesResponse)2 QueryRule (org.molgenis.data.QueryRule)2 AndNode (cz.jirutka.rsql.parser.ast.AndNode)1 OrNode (cz.jirutka.rsql.parser.ast.OrNode)1 Stream (java.util.stream.Stream)1