Search in sources :

Example 36 with Operator

use of jakarta.nosql.query.Operator in project jnosql-diana by eclipse.

the class FindByMethodQueryProviderTest method shouldReturnParserQuery13.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "findByAgeNotLike" })
public void shouldReturnParserQuery13(String query) {
    Operator operator = Operator.LIKE;
    String variable = "age";
    checkNotCondition(query, operator, variable);
}
Also used : Operator(jakarta.nosql.query.Operator) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 37 with Operator

use of jakarta.nosql.query.Operator in project jnosql-diana by eclipse.

the class FindByMethodQueryProviderTest method shouldReturnParserQuery15.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "findByAgeNotIn" })
public void shouldReturnParserQuery15(String query) {
    Operator operator = Operator.IN;
    String variable = "age";
    checkNotCondition(query, operator, variable);
}
Also used : Operator(jakarta.nosql.query.Operator) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 38 with Operator

use of jakarta.nosql.query.Operator in project jnosql-diana by eclipse.

the class FindByMethodQueryProviderTest method shouldReturnParserQuery27.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "findByAgeBetween" })
public void shouldReturnParserQuery27(String query) {
    Operator operator = Operator.BETWEEN;
    String entity = "entity";
    SelectQuery selectQuery = queryProvider.apply(query, entity);
    assertNotNull(selectQuery);
    assertEquals(entity, selectQuery.getEntity());
    assertTrue(selectQuery.getFields().isEmpty());
    assertTrue(selectQuery.getOrderBy().isEmpty());
    assertEquals(0, selectQuery.getLimit());
    assertEquals(0, selectQuery.getSkip());
    Optional<Where> where = selectQuery.getWhere();
    assertTrue(where.isPresent());
    Condition condition = where.get().getCondition();
    QueryValue<?> value = condition.getValue();
    assertEquals(operator, condition.getOperator());
    QueryValue<?>[] values = MethodArrayValue.class.cast(value).get();
    ParamQueryValue param1 = (ParamQueryValue) values[0];
    ParamQueryValue param2 = (ParamQueryValue) values[1];
    assertNotEquals(param2.get(), param1.get());
}
Also used : Operator(jakarta.nosql.query.Operator) SelectQuery(jakarta.nosql.query.SelectQuery) Condition(jakarta.nosql.query.Condition) ParamQueryValue(jakarta.nosql.query.ParamQueryValue) Where(jakarta.nosql.query.Where) ParamQueryValue(jakarta.nosql.query.ParamQueryValue) ConditionQueryValue(jakarta.nosql.query.ConditionQueryValue) QueryValue(jakarta.nosql.query.QueryValue) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 39 with Operator

use of jakarta.nosql.query.Operator in project jnosql-diana by eclipse.

the class FindByMethodQueryProviderTest method shouldReturnParserQuery4.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "findByAgeGreaterThan" })
public void shouldReturnParserQuery4(String query) {
    Operator operator = Operator.GREATER_THAN;
    String variable = "age";
    checkCondition(query, operator, variable);
}
Also used : Operator(jakarta.nosql.query.Operator) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 40 with Operator

use of jakarta.nosql.query.Operator in project jnosql-diana by eclipse.

the class FindByMethodQueryProviderTest method shouldReturnParserQuery8.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "findByAgeLessThan" })
public void shouldReturnParserQuery8(String query) {
    Operator operator = Operator.LESSER_THAN;
    String variable = "age";
    checkCondition(query, operator, variable);
}
Also used : Operator(jakarta.nosql.query.Operator) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Operator (jakarta.nosql.query.Operator)43 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)34 ValueSource (org.junit.jupiter.params.provider.ValueSource)34 Condition (jakarta.nosql.query.Condition)3 ConditionQueryValue (jakarta.nosql.query.ConditionQueryValue)3 ParamQueryValue (jakarta.nosql.query.ParamQueryValue)2 QueryValue (jakarta.nosql.query.QueryValue)2 Where (jakarta.nosql.query.Where)2 ArrayQueryValue (jakarta.nosql.query.ArrayQueryValue)1 DeleteQuery (jakarta.nosql.query.DeleteQuery)1 SelectQuery (jakarta.nosql.query.SelectQuery)1