Search in sources :

Example 1 with PutQuery

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

the class PutProviderTest method shouldReturnParserQuery1.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "put {12, \"Hunt\"}\n" })
public void shouldReturnParserQuery1(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 StringQueryValue);
    assertEquals("Hunt", StringQueryValue.class.cast(value).get());
    assertFalse(ttl.isPresent());
}
Also used : NumberQueryValue(jakarta.nosql.query.NumberQueryValue) Duration(java.time.Duration) PutQuery(jakarta.nosql.query.PutQuery) StringQueryValue(jakarta.nosql.query.StringQueryValue) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with PutQuery

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

the class PutProviderTest method shouldReturnParserQuery7.

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

Example 3 with PutQuery

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

the class PutProviderTest method shouldReturnParserQuery3.

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

Example 4 with PutQuery

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

the class PutProviderTest method shouldReturnParserQuery4.

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

Example 5 with PutQuery

use of jakarta.nosql.query.PutQuery 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)

Aggregations

PutQuery (jakarta.nosql.query.PutQuery)10 Duration (java.time.Duration)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 ValueSource (org.junit.jupiter.params.provider.ValueSource)8 ParamQueryValue (jakarta.nosql.query.ParamQueryValue)5 Params (jakarta.nosql.Params)2 Value (jakarta.nosql.Value)2 NumberQueryValue (jakarta.nosql.query.NumberQueryValue)2 StringQueryValue (jakarta.nosql.query.StringQueryValue)2 QueryException (jakarta.nosql.QueryException)1 KeyValueEntity (jakarta.nosql.keyvalue.KeyValueEntity)1