use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery12.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where stamina >= -10.23" })
public void shouldReturnParserQuery12(String query) {
ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
parser.query(query, manager, observer);
Mockito.verify(manager).delete(captor.capture());
ColumnDeleteQuery columnQuery = captor.getValue();
checkBaseQuery(columnQuery);
assertTrue(columnQuery.getCondition().isPresent());
ColumnCondition condition = columnQuery.getCondition().get();
assertEquals(Condition.GREATER_EQUALS_THAN, condition.getCondition());
assertEquals(Column.of("stamina", -10.23), condition.getColumn());
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery18.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where siblings = {\"apollo\": \"Brother\", \"Zeus\": \"Father\"}" })
public void shouldReturnParserQuery18(String query) {
ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
parser.query(query, manager, observer);
Mockito.verify(manager).delete(captor.capture());
ColumnDeleteQuery columnQuery = captor.getValue();
checkBaseQuery(columnQuery);
assertTrue(columnQuery.getCondition().isPresent());
ColumnCondition condition = columnQuery.getCondition().get();
assertEquals(Condition.EQUALS, condition.getCondition());
Column column = condition.getColumn();
List<Column> columns = column.get(new TypeReference<List<Column>>() {
});
assertThat(columns, containsInAnyOrder(Column.of("apollo", "Brother"), Column.of("Zeus", "Father")));
assertEquals("siblings", column.getName());
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery14.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where stamina < -10.23" })
public void shouldReturnParserQuery14(String query) {
ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
parser.query(query, manager, observer);
Mockito.verify(manager).delete(captor.capture());
ColumnDeleteQuery columnQuery = captor.getValue();
checkBaseQuery(columnQuery);
assertTrue(columnQuery.getCondition().isPresent());
ColumnCondition condition = columnQuery.getCondition().get();
assertEquals(Condition.LESSER_THAN, condition.getCondition());
assertEquals(Column.of("stamina", -10.23), condition.getColumn());
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery13.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where stamina <= -10.23" })
public void shouldReturnParserQuery13(String query) {
ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
parser.query(query, manager, observer);
Mockito.verify(manager).delete(captor.capture());
ColumnDeleteQuery columnQuery = captor.getValue();
checkBaseQuery(columnQuery);
assertTrue(columnQuery.getCondition().isPresent());
ColumnCondition condition = columnQuery.getCondition().get();
assertEquals(Condition.LESSER_EQUALS_THAN, condition.getCondition());
assertEquals(Column.of("stamina", -10.23), condition.getColumn());
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery26.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where name = \"Ada\" and age = 20 or" + " siblings = {\"apollo\": \"Brother\", \"Zeus\": \"Father\"} and birthday =" + " convert(\"2007-12-03\", java.time.LocalDate)" })
public void shouldReturnParserQuery26(String query) {
ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
parser.query(query, manager, observer);
Mockito.verify(manager).delete(captor.capture());
ColumnDeleteQuery columnQuery = captor.getValue();
checkBaseQuery(columnQuery);
assertTrue(columnQuery.getCondition().isPresent());
ColumnCondition condition = columnQuery.getCondition().get();
Column column = condition.getColumn();
assertEquals(Condition.AND, condition.getCondition());
List<ColumnCondition> conditions = column.get(new TypeReference<List<ColumnCondition>>() {
});
assertEquals(Condition.EQUALS, conditions.get(0).getCondition());
assertEquals(Condition.EQUALS, conditions.get(1).getCondition());
assertEquals(Condition.OR, conditions.get(2).getCondition());
assertEquals(Condition.EQUALS, conditions.get(3).getCondition());
}
Aggregations