Search in sources :

Example 21 with InsertQuery

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

the class InsertQueryProviderTest method shouldReturnParserQuery9.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "insert God (name = \"Diana\") 10 minute" })
public void shouldReturnParserQuery9(String query) {
    InsertQuery insertQuery = checkInsertFromStart(query);
    checkTTL(insertQuery, Duration.ofMinutes(10L));
}
Also used : InsertQuery(jakarta.nosql.query.InsertQuery) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 22 with InsertQuery

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

the class InsertQueryProviderTest method shouldReturnParserQuery14.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "insert Person {\"name\":\"Ada Lovelace\"}" })
public void shouldReturnParserQuery14(String query) {
    InsertQuery insertQuery = insertQueryProvider.apply(query);
    assertEquals("Person", insertQuery.getEntity());
    Assertions.assertTrue(insertQuery.getConditions().isEmpty());
    Assertions.assertTrue(insertQuery.getValue().isPresent());
    JSONQueryValue JSONQueryValue = insertQuery.getValue().get();
    JsonObject jsonObject = JSONQueryValue.get();
    assertEquals("Ada Lovelace", jsonObject.getString("name"));
}
Also used : InsertQuery(jakarta.nosql.query.InsertQuery) JsonObject(javax.json.JsonObject) JSONQueryValue(jakarta.nosql.query.JSONQueryValue) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

InsertQuery (jakarta.nosql.query.InsertQuery)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 ValueSource (org.junit.jupiter.params.provider.ValueSource)16 Condition (jakarta.nosql.query.Condition)7 JsonObject (javax.json.JsonObject)5 Params (jakarta.nosql.Params)4 JSONQueryValue (jakarta.nosql.query.JSONQueryValue)4 Duration (java.time.Duration)4 NumberQueryValue (jakarta.nosql.query.NumberQueryValue)3 QueryException (jakarta.nosql.QueryException)2 ColumnEntity (jakarta.nosql.column.ColumnEntity)2 DocumentEntity (jakarta.nosql.document.DocumentEntity)2 StringQueryValue (jakarta.nosql.query.StringQueryValue)2 Function (jakarta.nosql.query.Function)1 FunctionQueryValue (jakarta.nosql.query.FunctionQueryValue)1 ParamQueryValue (jakarta.nosql.query.ParamQueryValue)1 JsonArray (javax.json.JsonArray)1