use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class DocumentEntityTest method shouldRemoveDocumentByName.
@Test
public void shouldRemoveDocumentByName() {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
assertTrue(entity.remove("name"));
assertTrue(entity.isEmpty());
}
use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class DocumentsTest method shouldCreateDocument.
@Test
public void shouldCreateDocument() {
Document column = Documents.of("name", "Ada");
assertEquals("name", column.getName());
assertEquals("Ada", column.get());
}
use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery19.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where age = convert(12, java.lang.Integer)" })
public void shouldReturnParserQuery19(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.EQUALS, condition.getCondition());
assertEquals("age", document.getName());
assertEquals(Value.of(12), document.getValue());
}
use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery26.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete 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<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.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());
}
use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery22.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where name not like \"Ada\"" })
public void shouldReturnParserQuery22(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.NOT, condition.getCondition());
List<DocumentCondition> conditions = document.get(new TypeReference<List<DocumentCondition>>() {
});
DocumentCondition documentCondition = conditions.get(0);
assertEquals(Condition.LIKE, documentCondition.getCondition());
assertEquals(Document.of("name", "Ada"), documentCondition.getDocument());
}
Aggregations