use of jakarta.nosql.document.DocumentObserverParser in project jnosql-diana by eclipse.
the class DeleteQueryParser method getQuery.
private DocumentDeleteQuery getQuery(Params params, DocumentObserverParser observer, DeleteQuery deleteQuery) {
String collection = observer.fireEntity(deleteQuery.getEntity());
List<String> documents = deleteQuery.getFields().stream().map(f -> observer.fireField(collection, f)).collect(Collectors.toList());
DocumentCondition condition = null;
if (deleteQuery.getWhere().isPresent()) {
condition = deleteQuery.getWhere().map(c -> Conditions.getCondition(c, params, observer, collection)).get();
}
return new DefaultDocumentDeleteQuery(collection, condition, documents);
}
use of jakarta.nosql.document.DocumentObserverParser in project jnosql-diana by eclipse.
the class SelectQueryParserTest method shouldReturnParserQuery4.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God order by name asc" })
public void shouldReturnParserQuery4(String query) {
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
DocumentObserverParser observer = new DocumentObserverParser() {
};
parser.query(query, documentCollection, observer);
Mockito.verify(documentCollection).select(captor.capture());
DocumentQuery documentQuery = captor.getValue();
assertTrue(documentQuery.getDocuments().isEmpty());
assertThat(documentQuery.getSorts(), contains(Sort.of("name", SortType.ASC)));
assertEquals(0L, documentQuery.getLimit());
assertEquals(0L, documentQuery.getSkip());
assertEquals("God", documentQuery.getDocumentCollection());
assertFalse(documentQuery.getCondition().isPresent());
}
Aggregations