use of jakarta.nosql.column.ColumnDeleteQuery 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.ColumnDeleteQuery 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.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldDeleteNegate.
@Test
public void shouldDeleteNegate() {
String columnFamily = "columnFamily";
ColumnDeleteQuery query = delete().from(columnFamily).where("city").not().eq("Assis").and("name").not().eq("Lucas").build();
ColumnCondition condition = query.getCondition().orElseThrow(RuntimeException::new);
assertEquals(columnFamily, query.getColumnFamily());
Column column = condition.getColumn();
List<ColumnCondition> conditions = column.get(new TypeReference<List<ColumnCondition>>() {
});
assertEquals(Condition.AND, condition.getCondition());
assertThat(conditions, containsInAnyOrder(eq(Column.of("city", "Assis")).negate(), eq(Column.of("name", "Lucas")).negate()));
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameLike.
@Test
public void shouldSelectWhereNameLike() {
String columnFamily = "columnFamily";
String name = "Ada Lovelace";
ColumnDeleteQuery query = delete().from(columnFamily).where("name").like(name).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
assertTrue(query.getColumns().isEmpty());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(Condition.LIKE, condition.getCondition());
assertEquals("name", column.getName());
assertEquals(name, column.get());
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameGt.
@Test
public void shouldSelectWhereNameGt() {
String columnFamily = "columnFamily";
Number value = 10;
ColumnDeleteQuery query = delete().from(columnFamily).where("name").gt(value).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
assertTrue(query.getColumns().isEmpty());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(Condition.GREATER_THAN, condition.getCondition());
assertEquals("name", column.getName());
assertEquals(value, column.get());
}
Aggregations