use of jakarta.nosql.query.SelectQuery in project jnosql-diana by eclipse.
the class FindByMethodQueryProviderTest method shouldRunQuery31.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "findBySalary_CurrencyAndName" })
public void shouldRunQuery31(String query) {
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();
Assertions.assertEquals(Operator.AND, condition.getOperator());
final QueryValue<?> value = condition.getValue();
Condition condition1 = ConditionQueryValue.class.cast(value).get().get(0);
Condition condition2 = ConditionQueryValue.class.cast(value).get().get(1);
assertEquals("salary.currency", condition1.getName());
assertEquals("name", condition2.getName());
}
use of jakarta.nosql.query.SelectQuery in project jnosql-diana by eclipse.
the class FindByMethodQueryProviderTest method checkNotCondition.
private void checkNotCondition(String query, Operator operator, String variable) {
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.NOT, condition.getOperator());
assertEquals("_NOT", condition.getName());
assertTrue(value instanceof ConditionQueryValue);
Condition condition1 = ConditionQueryValue.class.cast(value).get().get(0);
QueryValue<?> param = condition1.getValue();
assertEquals(operator, condition1.getOperator());
assertTrue(ParamQueryValue.class.cast(param).get().contains(variable));
}
use of jakarta.nosql.query.SelectQuery 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());
}
use of jakarta.nosql.query.SelectQuery in project jnosql-diana by eclipse.
the class FindByMethodQueryProviderTest method checkOrderBy.
private void checkOrderBy(String query, SortType type, SortType type2) {
String entity = "entity";
SelectQuery selectQuery = queryProvider.apply(query, entity);
assertNotNull(selectQuery);
assertEquals(entity, selectQuery.getEntity());
List<Sort> sorts = selectQuery.getOrderBy();
assertEquals(2, sorts.size());
Sort sort = sorts.get(0);
assertEquals("name", sort.getName());
assertEquals(type, sort.getType());
Sort sort2 = sorts.get(1);
assertEquals("age", sort2.getName());
assertEquals(type2, sort2.getType());
}
use of jakarta.nosql.query.SelectQuery in project jnosql-diana by eclipse.
the class FindByMethodQueryProviderTest method shouldRunQuery29.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "findBySalary_Currency" })
public void shouldRunQuery29(String query) {
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());
assertTrue(where.isPresent());
Condition condition = where.get().getCondition();
Assertions.assertEquals(Operator.EQUALS, condition.getOperator());
assertEquals("salary.currency", condition.getName());
}
Aggregations