use of jakarta.nosql.query.DeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryProviderTest method shouldReturnParserQuery16.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where name like \"Ada\"" })
public void shouldReturnParserQuery16(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.LIKE, condition.getOperator());
assertEquals("name", condition.getName());
assertTrue(value instanceof StringQueryValue);
assertEquals("Ada", StringQueryValue.class.cast(value).get());
}
use of jakarta.nosql.query.DeleteQuery 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"));
}
use of jakarta.nosql.query.DeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryProviderTest method shouldReturnParserQuery5.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where stamina >= 10.23" })
public void shouldReturnParserQuery5(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.GREATER_EQUALS_THAN, condition.getOperator());
assertEquals("stamina", condition.getName());
assertTrue(value instanceof NumberQueryValue);
assertEquals(10.23, value.get());
}
use of jakarta.nosql.query.DeleteQuery in project jnosql-diana by eclipse.
the class DeleteByMethodQueryProviderTest method shouldRunQuery30.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "deleteBySalary_CurrencyAndCredential_Role" })
public void shouldRunQuery30(String query) {
String entity = "entity";
DeleteQuery deleteQuery = queryProvider.apply(query, entity);
assertNotNull(deleteQuery);
assertEquals(entity, deleteQuery.getEntity());
assertTrue(deleteQuery.getFields().isEmpty());
Optional<Where> where = deleteQuery.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("credential.role", condition2.getName());
}
use of jakarta.nosql.query.DeleteQuery in project jnosql-diana by eclipse.
the class DeleteByMethodQueryProviderTest method checkEqualsQuery.
private void checkEqualsQuery(String query, String entity) {
DeleteQuery deleteQuery = queryProvider.apply(query, entity);
assertNotNull(deleteQuery);
assertEquals(entity, deleteQuery.getEntity());
assertTrue(deleteQuery.getFields().isEmpty());
Optional<Where> where = deleteQuery.getWhere();
assertTrue(where.isPresent());
Condition condition = where.get().getCondition();
QueryValue<?> value = condition.getValue();
assertEquals(Operator.EQUALS, condition.getOperator());
assertEquals("name", condition.getName());
assertTrue(value instanceof ParamQueryValue);
assertTrue(ParamQueryValue.class.cast(value).get().contains("name"));
}
Aggregations