use of jakarta.nosql.document.Document 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<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.IN, condition.getCondition());
assertEquals("name", document.getName());
List<String> values = document.get(new TypeReference<List<String>>() {
});
assertThat(values, containsInAnyOrder("Ada", "Apollo"));
}
use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery18.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where siblings = {\"apollo\": \"Brother\", \"Zeus\": \"Father\"}" })
public void shouldReturnParserQuery18(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());
Document document = condition.getDocument();
List<Document> documents = document.get(new TypeReference<List<Document>>() {
});
assertThat(documents, containsInAnyOrder(Document.of("apollo", "Brother"), Document.of("Zeus", "Father")));
assertEquals("siblings", document.getName());
}
use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery21.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where name like \"Ada\"" })
public void shouldReturnParserQuery21(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.LIKE, condition.getCondition());
assertEquals("name", document.getName());
assertEquals("Ada", document.get());
}
use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class SelectQueryParserTest method shouldReturnParserQuery21.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where name like \"Ada\"" })
public void shouldReturnParserQuery21(String query) {
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
parser.query(query, documentCollection, observer);
Mockito.verify(documentCollection).select(captor.capture());
DocumentQuery documentQuery = captor.getValue();
checkBaseQuery(documentQuery, 0L, 0L);
assertTrue(documentQuery.getCondition().isPresent());
DocumentCondition condition = documentQuery.getCondition().get();
Document document = condition.getDocument();
assertEquals(Condition.LIKE, condition.getCondition());
assertEquals("name", document.getName());
assertEquals("Ada", document.get());
}
use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class SelectQueryParserTest method shouldReturnParserQuery18.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where siblings = {\"apollo\": \"Brother\", \"Zeus\": \"Father\"}" })
public void shouldReturnParserQuery18(String query) {
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
parser.query(query, documentCollection, observer);
Mockito.verify(documentCollection).select(captor.capture());
DocumentQuery documentQuery = captor.getValue();
checkBaseQuery(documentQuery, 0L, 0L);
assertTrue(documentQuery.getCondition().isPresent());
DocumentCondition condition = documentQuery.getCondition().get();
assertEquals(Condition.EQUALS, condition.getCondition());
Document document = condition.getDocument();
List<Document> documents = document.get(new TypeReference<List<Document>>() {
});
assertThat(documents, containsInAnyOrder(Document.of("apollo", "Brother"), Document.of("Zeus", "Father")));
assertEquals("siblings", document.getName());
}
Aggregations