Search in sources :

Example 26 with NumberQueryValue

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

the class SelectQueryProviderTest method shouldReturnParserQuery10.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select  * from God where stamina > 10.23" })
public void shouldReturnParserQuery10(String query) {
    SelectQuery selectQuery = checkSelectFromStart(query);
    assertTrue(selectQuery.getWhere().isPresent());
    Where where = selectQuery.getWhere().get();
    Condition condition = where.getCondition();
    QueryValue<?> value = condition.getValue();
    Assertions.assertEquals(Operator.GREATER_THAN, condition.getOperator());
    assertEquals("stamina", condition.getName());
    assertTrue(value instanceof NumberQueryValue);
    assertEquals(10.23, value.get());
}
Also used : SelectQuery(jakarta.nosql.query.SelectQuery) Condition(jakarta.nosql.query.Condition) NumberQueryValue(jakarta.nosql.query.NumberQueryValue) Where(jakarta.nosql.query.Where) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 27 with NumberQueryValue

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

the class UpdateQueryProviderTest method shouldReturnParserQuery2.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "update God (stamina = 32.23)" })
public void shouldReturnParserQuery2(String query) {
    UpdateQuery updateQuery = checkUpdateFromStart(query);
    List<Condition> conditions = updateQuery.getConditions();
    assertEquals(1, conditions.size());
    Condition condition = conditions.get(0);
    assertEquals("stamina", condition.getName());
    assertEquals(Operator.EQUALS, condition.getOperator());
    QueryValue<?> value = condition.getValue();
    assertTrue(value instanceof NumberQueryValue);
    assertEquals(32.23, NumberQueryValue.class.cast(value).get());
}
Also used : Condition(jakarta.nosql.query.Condition) NumberQueryValue(jakarta.nosql.query.NumberQueryValue) UpdateQuery(jakarta.nosql.query.UpdateQuery) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 28 with NumberQueryValue

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

the class PutProviderTest method shouldReturnParserQuery2.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "put {12, 12.12}\n" })
public void shouldReturnParserQuery2(String query) {
    PutQuery putQuery = provider.apply(query);
    QueryValue<?> key = putQuery.getKey();
    QueryValue<?> value = putQuery.getValue();
    Optional<Duration> ttl = putQuery.getTtl();
    assertTrue(key instanceof NumberQueryValue);
    assertEquals(12L, NumberQueryValue.class.cast(key).get());
    assertTrue(value instanceof NumberQueryValue);
    assertEquals(12.12, NumberQueryValue.class.cast(value).get());
    assertFalse(ttl.isPresent());
}
Also used : NumberQueryValue(jakarta.nosql.query.NumberQueryValue) Duration(java.time.Duration) PutQuery(jakarta.nosql.query.PutQuery) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 29 with NumberQueryValue

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

the class GetProviderTest method shouldReturnParserQuery4.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "get -12.12" })
public void shouldReturnParserQuery4(String query) {
    GetQuery getQuery = queryProvider.apply(query);
    List<QueryValue<?>> keys = getQuery.getKeys();
    assertEquals(1, keys.size());
    QueryValue<?> key = keys.get(0);
    assertTrue(key instanceof NumberQueryValue);
    assertEquals(-12.12, NumberQueryValue.class.cast(key).get());
}
Also used : NumberQueryValue(jakarta.nosql.query.NumberQueryValue) GetQuery(jakarta.nosql.query.GetQuery) NumberQueryValue(jakarta.nosql.query.NumberQueryValue) QueryValue(jakarta.nosql.query.QueryValue) ArrayQueryValue(jakarta.nosql.query.ArrayQueryValue) StringQueryValue(jakarta.nosql.query.StringQueryValue) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 30 with NumberQueryValue

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

the class InsertQueryProviderTest method shouldReturnParserQuery2.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "insert God (stamina = 32.23)" })
public void shouldReturnParserQuery2(String query) {
    InsertQuery insertQuery = checkInsertFromStart(query);
    List<Condition> conditions = insertQuery.getConditions();
    assertEquals(1, conditions.size());
    Condition condition = conditions.get(0);
    assertEquals("stamina", condition.getName());
    assertEquals(Operator.EQUALS, condition.getOperator());
    QueryValue<?> value = condition.getValue();
    assertTrue(value instanceof NumberQueryValue);
    assertEquals(32.23, NumberQueryValue.class.cast(value).get());
    assertFalse(insertQuery.getTtl().isPresent());
}
Also used : Condition(jakarta.nosql.query.Condition) NumberQueryValue(jakarta.nosql.query.NumberQueryValue) InsertQuery(jakarta.nosql.query.InsertQuery) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

NumberQueryValue (jakarta.nosql.query.NumberQueryValue)36 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)36 ValueSource (org.junit.jupiter.params.provider.ValueSource)36 Condition (jakarta.nosql.query.Condition)26 StringQueryValue (jakarta.nosql.query.StringQueryValue)21 Where (jakarta.nosql.query.Where)20 ConditionQueryValue (jakarta.nosql.query.ConditionQueryValue)10 DeleteQuery (jakarta.nosql.query.DeleteQuery)10 JSONQueryValue (jakarta.nosql.query.JSONQueryValue)10 SelectQuery (jakarta.nosql.query.SelectQuery)10 JsonObject (javax.json.JsonObject)10 ArrayQueryValue (jakarta.nosql.query.ArrayQueryValue)8 QueryValue (jakarta.nosql.query.QueryValue)8 DelQuery (jakarta.nosql.query.DelQuery)4 Function (jakarta.nosql.query.Function)4 FunctionQueryValue (jakarta.nosql.query.FunctionQueryValue)4 GetQuery (jakarta.nosql.query.GetQuery)4 InsertQuery (jakarta.nosql.query.InsertQuery)3 UpdateQuery (jakarta.nosql.query.UpdateQuery)3 PutQuery (jakarta.nosql.query.PutQuery)2