use of jakarta.nosql.document.DocumentCondition 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.DocumentCondition in project jnosql-diana by eclipse.
the class SelectQueryParserTest method shouldReturnParserQuery10.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where age = 10" })
public void shouldReturnParserQuery10(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());
assertEquals(Document.of("age", 10L), condition.getDocument());
}
use of jakarta.nosql.document.DocumentCondition in project jnosql-diana by eclipse.
the class SelectQueryParserTest method shouldReturnParserQuery12.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where stamina >= -10.23" })
public void shouldReturnParserQuery12(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();
checkBaseQuery(documentQuery, 0L, 0L);
assertTrue(documentQuery.getCondition().isPresent());
DocumentCondition condition = documentQuery.getCondition().get();
assertEquals(Condition.GREATER_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 shouldReturnParserQuery16.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where name = \"diana\"" })
public void shouldReturnParserQuery16(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());
assertEquals(Document.of("name", "diana"), condition.getDocument());
}
use of jakarta.nosql.document.DocumentCondition in project jnosql-diana by eclipse.
the class SelectQueryParserTest method shouldReturnParserQuery14.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where stamina < -10.23" })
public void shouldReturnParserQuery14(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_THAN, condition.getCondition());
assertEquals(Document.of("stamina", -10.23), condition.getDocument());
}
Aggregations