use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultColumnQueryParserTest method shouldReturnParserQuery1.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God" })
public void shouldReturnParserQuery1(String query) {
ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
parser.query(query, manager, ColumnObserverParser.EMPTY);
Mockito.verify(manager).delete(captor.capture());
ColumnDeleteQuery columnDeleteQuery = captor.getValue();
assertTrue(columnDeleteQuery.getColumns().isEmpty());
assertEquals("God", columnDeleteQuery.getColumnFamily());
assertFalse(columnDeleteQuery.getCondition().isPresent());
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameLt.
@Test
public void shouldSelectWhereNameLt() {
String columnFamily = "columnFamily";
Number value = 10;
ColumnDeleteQuery query = delete().from(columnFamily).where("name").lt(value).build();
ColumnCondition columnCondition = query.getCondition().get();
Column column = columnCondition.getColumn();
assertTrue(query.getColumns().isEmpty());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(Condition.LESSER_THAN, columnCondition.getCondition());
assertEquals("name", column.getName());
assertEquals(value, column.get());
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameBetween.
@Test
public void shouldSelectWhereNameBetween() {
String columnFamily = "columnFamily";
Number valueA = 10;
Number valueB = 20;
ColumnDeleteQuery query = delete().from(columnFamily).where("name").between(valueA, valueB).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
assertTrue(query.getColumns().isEmpty());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(Condition.BETWEEN, condition.getCondition());
assertEquals("name", column.getName());
assertThat(column.get(new TypeReference<List<Number>>() {
}), Matchers.contains(10, 20));
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameOr.
@Test
public void shouldSelectWhereNameOr() {
String columnFamily = "columnFamily";
String name = "Ada Lovelace";
ColumnDeleteQuery query = delete().from(columnFamily).where("name").eq(name).or("age").gt(10).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
List<ColumnCondition> conditions = column.get(new TypeReference<List<ColumnCondition>>() {
});
assertEquals(Condition.OR, condition.getCondition());
assertThat(conditions, Matchers.containsInAnyOrder(ColumnCondition.eq(Column.of("name", name)), ColumnCondition.gt(Column.of("age", 10))));
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameGte.
@Test
public void shouldSelectWhereNameGte() {
String columnFamily = "columnFamily";
Number value = 10;
ColumnDeleteQuery query = delete().from(columnFamily).where("name").gte(value).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
assertTrue(query.getColumns().isEmpty());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(Condition.GREATER_EQUALS_THAN, condition.getCondition());
assertEquals("name", column.getName());
assertEquals(value, column.get());
}
Aggregations