use of jakarta.nosql.query.ArrayQueryValue in project jnosql-diana by eclipse.
the class SelectQueryProviderTest method shouldReturnParserQuery18.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where name = {\"diana\", 17, 20.21}" })
public void shouldReturnParserQuery18(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.EQUALS, condition.getOperator());
assertEquals("name", condition.getName());
assertTrue(value instanceof ArrayQueryValue);
List<?> values = Stream.of(ArrayQueryValue.class.cast(value).get()).map(QueryValue::get).collect(toList());
assertThat(values, contains("diana", 17L, 20.21));
}
use of jakarta.nosql.query.ArrayQueryValue in project jnosql-diana by eclipse.
the class SelectQueryProviderTest method shouldReturnParserQuery14.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where age between 10 and 30" })
public void shouldReturnParserQuery14(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.BETWEEN, condition.getOperator());
assertEquals("age", condition.getName());
assertTrue(value instanceof ArrayQueryValue);
ArrayQueryValue arrayValue = ArrayQueryValue.class.cast(value);
QueryValue<?>[] values = arrayValue.get();
assertThat(Stream.of(values).map(QueryValue::get).collect(toList()), contains(10L, 30L));
}
use of jakarta.nosql.query.ArrayQueryValue in project jnosql-diana by eclipse.
the class SelectQueryProviderTest method shouldReturnParserQuery17.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where name = {\"diana\"}" })
public void shouldReturnParserQuery17(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.EQUALS, condition.getOperator());
assertEquals("name", condition.getName());
assertTrue(value instanceof ArrayQueryValue);
List<?> values = Stream.of(ArrayQueryValue.class.cast(value).get()).map(QueryValue::get).collect(toList());
assertThat(values, contains("diana"));
}
use of jakarta.nosql.query.ArrayQueryValue in project jnosql-diana by eclipse.
the class RemoveProviderTest method shouldReturnParserQuery5.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "del {1,12}" })
public void shouldReturnParserQuery5(String query) {
DelQuery delQuery = provider.apply(query);
List<QueryValue<?>> keys = delQuery.getKeys();
assertEquals(1, keys.size());
QueryValue<?> key = keys.get(0);
assertTrue(key instanceof ArrayQueryValue);
QueryValue<?>[] values = ArrayQueryValue.class.cast(key).get();
MatcherAssert.assertThat(Arrays.stream(values).map(QueryValue::get).collect(Collectors.toList()), Matchers.contains(1L, 12L));
}
use of jakarta.nosql.query.ArrayQueryValue in project jnosql-diana by eclipse.
the class DeleteQueryProviderTest method shouldReturnParserQuery15.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where name in (\"Ada\", \"Apollo\")" })
public void shouldReturnParserQuery15(String query) {
DeleteQuery deleteQuery = checkDeleteFromStart(query);
assertTrue(deleteQuery.getWhere().isPresent());
Where where = deleteQuery.getWhere().get();
Condition condition = where.getCondition();
QueryValue<?> value = condition.getValue();
Assertions.assertEquals(Operator.IN, condition.getOperator());
assertEquals("name", condition.getName());
assertTrue(value instanceof ArrayQueryValue);
List<?> values = Stream.of(ArrayQueryValue.class.cast(value).get()).map(QueryValue::get).collect(toList());
assertThat(values, contains("Ada", "Apollo"));
}
Aggregations