use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery1.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete name, address from God" })
public void shouldReturnParserQuery1(String query) {
ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
parser.query(query, manager, observer);
Mockito.verify(manager).delete(captor.capture());
ColumnDeleteQuery columnQuery = captor.getValue();
assertThat(columnQuery.getColumns(), contains("name", "address"));
assertEquals("God", columnQuery.getColumnFamily());
assertFalse(columnQuery.getCondition().isPresent());
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery19.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where age = convert(12, java.lang.Integer)" })
public void shouldReturnParserQuery19(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.EQUALS, condition.getCondition());
assertEquals("age", column.getName());
assertEquals(Value.of(12), column.getValue());
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldExecutePrepareStatement.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where age = @age" })
public void shouldExecutePrepareStatement(String query) {
ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
ColumnPreparedStatement prepare = parser.prepare(query, manager, observer);
prepare.bind("age", 12);
prepare.getResult();
Mockito.verify(manager).delete(captor.capture());
ColumnDeleteQuery 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());
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery24.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where name = \"Ada\" or age = 20" })
public void shouldReturnParserQuery24(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.OR, condition.getCondition());
List<ColumnCondition> conditions = column.get(new TypeReference<List<ColumnCondition>>() {
});
assertThat(conditions, contains(eq(Column.of("name", "Ada")), eq(Column.of("age", 20L))));
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery22.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where name not like \"Ada\"" })
public void shouldReturnParserQuery22(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.NOT, condition.getCondition());
List<ColumnCondition> conditions = column.get(new TypeReference<List<ColumnCondition>>() {
});
ColumnCondition columnCondition = conditions.get(0);
assertEquals(Condition.LIKE, columnCondition.getCondition());
assertEquals(Column.of("name", "Ada"), columnCondition.getColumn());
}
Aggregations