use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery16.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where name = \"diana\"" })
public void shouldReturnParserQuery16(String query) {
ArgumentCaptor<DocumentDeleteQuery> captor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
parser.query(query, documentCollection, observer);
Mockito.verify(documentCollection).delete(captor.capture());
DocumentDeleteQuery documentQuery = captor.getValue();
checkBaseQuery(documentQuery);
assertTrue(documentQuery.getCondition().isPresent());
DocumentCondition condition = documentQuery.getCondition().get();
assertEquals(Condition.EQUALS, condition.getCondition());
assertEquals(Document.of("name", "diana"), condition.getDocument());
}
use of jakarta.nosql.document.DocumentDeleteQuery 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<DocumentDeleteQuery> captor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
parser.query(query, documentCollection, observer);
Mockito.verify(documentCollection).delete(captor.capture());
DocumentDeleteQuery documentQuery = captor.getValue();
assertThat(documentQuery.getDocuments(), contains("name", "address"));
assertEquals("God", documentQuery.getDocumentCollection());
assertFalse(documentQuery.getCondition().isPresent());
}
use of jakarta.nosql.document.DocumentDeleteQuery 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<DocumentDeleteQuery> captor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
parser.query(query, documentCollection, observer);
Mockito.verify(documentCollection).delete(captor.capture());
DocumentDeleteQuery documentQuery = captor.getValue();
checkBaseQuery(documentQuery);
assertTrue(documentQuery.getCondition().isPresent());
DocumentCondition condition = documentQuery.getCondition().get();
assertEquals(Condition.LESSER_EQUALS_THAN, condition.getCondition());
assertEquals(Document.of("stamina", -10.23), condition.getDocument());
}
use of jakarta.nosql.document.DocumentDeleteQuery 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<DocumentDeleteQuery> captor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
parser.query(query, documentCollection, observer);
Mockito.verify(documentCollection).delete(captor.capture());
DocumentDeleteQuery documentQuery = captor.getValue();
checkBaseQuery(documentQuery);
assertTrue(documentQuery.getCondition().isPresent());
DocumentCondition condition = documentQuery.getCondition().get();
Document document = condition.getDocument();
assertEquals(Condition.EQUALS, condition.getCondition());
assertEquals("age", document.getName());
assertEquals(Value.of(12), document.getValue());
}
use of jakarta.nosql.document.DocumentDeleteQuery 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<DocumentDeleteQuery> captor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
parser.query(query, documentCollection, observer);
Mockito.verify(documentCollection).delete(captor.capture());
DocumentDeleteQuery documentQuery = captor.getValue();
checkBaseQuery(documentQuery);
assertTrue(documentQuery.getCondition().isPresent());
DocumentCondition condition = documentQuery.getCondition().get();
Document document = condition.getDocument();
assertEquals(Condition.AND, condition.getCondition());
List<DocumentCondition> conditions = document.get(new TypeReference<List<DocumentCondition>>() {
});
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