use of jakarta.nosql.document.DocumentCondition in project jnosql-diana by eclipse.
the class SelectQueryParserTest method shouldReturnParserQuery13.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where stamina <= -10.23" })
public void shouldReturnParserQuery13(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.LESSER_EQUALS_THAN, condition.getCondition());
assertEquals(Document.of("stamina", -10.23), condition.getDocument());
}
use of jakarta.nosql.document.DocumentCondition in project jnosql-diana by eclipse.
the class SelectQueryParserTest method shouldReturnParserQuery15.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where age between 10 and 30" })
public void shouldReturnParserQuery15(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.BETWEEN, condition.getCondition());
assertEquals(Document.of("age", Arrays.asList(10L, 30L)), condition.getDocument());
}
use of jakarta.nosql.document.DocumentCondition 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());
}
use of jakarta.nosql.document.DocumentCondition in project jnosql-diana by eclipse.
the class SelectQueryParserTest method shouldReturnParserQuery24.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where name = \"Ada\" or age = 20" })
public void shouldReturnParserQuery24(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.OR, condition.getCondition());
List<DocumentCondition> conditions = document.get(new TypeReference<List<DocumentCondition>>() {
});
assertThat(conditions, contains(eq(Document.of("name", "Ada")), eq(Document.of("age", 20L))));
}
use of jakarta.nosql.document.DocumentCondition in project jnosql-diana by eclipse.
the class SelectQueryParserTest method shouldReturnParserQuery26.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * 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<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.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