use of org.jnosql.diana.api.document.DocumentQuery in project jnosql-diana-driver by eclipse.
the class CouchbaseDocumentCollectionManagerTest method shouldSaveSetDocument.
@Test
public void shouldSaveSetDocument() throws InterruptedException {
Set<String> set = new HashSet<>();
set.add("Acarajé");
set.add("Munguzá");
DocumentEntity entity = DocumentEntity.of(COLLECTION_NAME);
entity.add(Document.of("_id", "id"));
entity.add(Document.of("foods", set));
entityManager.insert(entity);
Document id = entity.find("_id").get();
Thread.sleep(1_000L);
DocumentQuery query = select().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
DocumentEntity entityFound = entityManager.singleResult(query).get();
Optional<Document> foods = entityFound.find("foods");
Set<String> setFoods = foods.get().get(new TypeReference<Set<String>>() {
});
assertEquals(set, setFoods);
}
use of org.jnosql.diana.api.document.DocumentQuery in project jnosql-diana-driver by eclipse.
the class QueryAQLConverterTest method shouldRunEqualsQueryAnd.
@Test
public void shouldRunEqualsQueryAnd() {
DocumentQuery query = select().from("collection").where("name").eq("value").and("age").lte(10).build();
AQLQueryResult convert = QueryAQLConverter.select(query);
String aql = convert.getQuery();
Map<String, Object> values = convert.getValues();
assertEquals("value", values.get("name"));
assertEquals("FOR c IN collection FILTER c.name == @name AND c.age <= @age RETURN c", aql);
}
use of org.jnosql.diana.api.document.DocumentQuery in project jnosql-diana-driver by eclipse.
the class QueryAQLConverterTest method shouldRunEqualsQueryOr.
@Test
public void shouldRunEqualsQueryOr() {
DocumentQuery query = select().from("collection").where("name").eq("value").or("age").lte(10).build();
AQLQueryResult convert = QueryAQLConverter.select(query);
String aql = convert.getQuery();
Map<String, Object> values = convert.getValues();
assertEquals("value", values.get("name"));
assertEquals("FOR c IN collection FILTER c.name == @name OR c.age <= @age RETURN c", aql);
}
use of org.jnosql.diana.api.document.DocumentQuery in project jnosql-diana-driver by eclipse.
the class QueryAQLConverterTest method shouldRunEqualsQueryNot.
@Test
public void shouldRunEqualsQueryNot() {
DocumentQuery query = select().from("collection").where("name").not().eq("value").build();
AQLQueryResult convert = QueryAQLConverter.select(query);
String aql = convert.getQuery();
Map<String, Object> values = convert.getValues();
assertEquals("value", values.get("name"));
assertEquals("FOR c IN collection FILTER NOT c.name == @name RETURN c", aql);
}
use of org.jnosql.diana.api.document.DocumentQuery in project jnosql-diana-driver by eclipse.
the class QueryAQLConverterTest method shouldRunEqualsQuerySort2.
@Test
public void shouldRunEqualsQuerySort2() {
DocumentQuery query = select().from("collection").where("name").eq("value").orderBy("name").asc().orderBy("age").desc().build();
AQLQueryResult convert = QueryAQLConverter.select(query);
String aql = convert.getQuery();
Map<String, Object> values = convert.getValues();
assertEquals("value", values.get("name"));
assertEquals("FOR c IN collection FILTER c.name == @name SORT c.name ASC , c.age DESC RETURN c", aql);
}
Aggregations