use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameEq.
@Test
public void shouldSelectWhereNameEq() {
String documentCollection = "documentCollection";
String name = "Ada Lovelace";
DocumentQuery query = select().from(documentCollection).where("name").eq(name).build();
DocumentCondition condition = query.getCondition().get();
Document document = condition.getDocument();
assertTrue(query.getDocuments().isEmpty());
assertEquals(documentCollection, query.getDocumentCollection());
assertEquals(Condition.EQUALS, condition.getCondition());
assertEquals("name", document.getName());
assertEquals(name, document.get());
}
use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameNot.
@Test
public void shouldSelectWhereNameNot() {
String documentCollection = "documentCollection";
String name = "Ada Lovelace";
DocumentQuery query = select().from(documentCollection).where("name").not().eq(name).build();
DocumentCondition condition = query.getCondition().get();
Document column = condition.getDocument();
DocumentCondition negate = column.get(DocumentCondition.class);
assertTrue(query.getDocuments().isEmpty());
assertEquals(documentCollection, query.getDocumentCollection());
assertEquals(Condition.NOT, condition.getCondition());
assertEquals(Condition.EQUALS, negate.getCondition());
assertEquals("name", negate.getDocument().getName());
assertEquals(name, negate.getDocument().get());
}
use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameAnd.
@Test
public void shouldSelectWhereNameAnd() {
String documentCollection = "documentCollection";
String name = "Ada Lovelace";
DocumentQuery query = select().from(documentCollection).where("name").eq(name).and("age").gt(10).build();
DocumentCondition condition = query.getCondition().get();
Document document = condition.getDocument();
List<DocumentCondition> conditions = document.get(new TypeReference<List<DocumentCondition>>() {
});
assertEquals(Condition.AND, condition.getCondition());
assertThat(conditions, Matchers.containsInAnyOrder(eq(Document.of("name", name)), DocumentCondition.gt(Document.of("age", 10))));
}
use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class DocumentParamsTest method shouldSetParameter.
@Test
public void shouldSetParameter() {
Params params = Params.newParams();
Value name = params.add("name");
Document document = Document.of("name", name);
params.bind("name", "Ada Lovelace");
assertEquals("Ada Lovelace", document.get());
params.bind("name", "Diana");
assertEquals("Diana", document.get());
}
use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class DocumentTest method shouldReturnGetObject.
@Test
public void shouldReturnGetObject() {
Value value = Value.of("text");
Document document = Document.of("name", value);
assertEquals(value.get(), document.get());
}
Aggregations