use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery15.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where age between 10 and 30" })
public void shouldReturnParserQuery15(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.BETWEEN, condition.getCondition());
assertEquals(Column.of("age", Arrays.asList(10L, 30L)), condition.getColumn());
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery20.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where name in (\"Ada\", \"Apollo\")" })
public void shouldReturnParserQuery20(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.IN, condition.getCondition());
assertEquals("name", column.getName());
List<String> values = column.get(new TypeReference<List<String>>() {
});
assertThat(values, containsInAnyOrder("Ada", "Apollo"));
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery11.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where stamina > 10.23" })
public void shouldReturnParserQuery11(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_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 SelectQueryParserTest method shouldReturnParserQuery21.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where name like \"Ada\"" })
public void shouldReturnParserQuery21(String query) {
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
parser.query(query, manager, observer);
Mockito.verify(manager).select(captor.capture());
ColumnQuery columnQuery = captor.getValue();
checkBaseQuery(columnQuery, 0L, 0L);
assertTrue(columnQuery.getCondition().isPresent());
ColumnCondition condition = columnQuery.getCondition().get();
Column column = condition.getColumn();
assertEquals(Condition.LIKE, condition.getCondition());
assertEquals("name", column.getName());
assertEquals("Ada", column.get());
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DefaultColumnQueryParserTest method shouldReturnEmptySingleResult.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where age = @age" })
public void shouldReturnEmptySingleResult(String query) {
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
Mockito.when(manager.select(Mockito.any(ColumnQuery.class))).thenReturn(Stream.empty());
ColumnPreparedStatement prepare = parser.prepare(query, manager, ColumnObserverParser.EMPTY);
prepare.bind("age", 12);
final Optional<ColumnEntity> result = prepare.getSingleResult();
Mockito.verify(manager).select(captor.capture());
ColumnQuery columnQuery = captor.getValue();
ColumnCondition columnCondition = columnQuery.getCondition().get();
Column column = columnCondition.getColumn();
assertEquals(Condition.EQUALS, columnCondition.getCondition());
assertEquals("age", column.getName());
assertEquals(12, column.get());
assertFalse(result.isPresent());
}
Aggregations