use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldDeleteDocuments.
@Test
public void shouldDeleteDocuments() {
String documentCollection = "documentCollection";
DocumentDeleteQuery query = delete("document", "document2").from(documentCollection).build();
assertThat(query.getDocuments(), containsInAnyOrder("document", "document2"));
assertFalse(query.getCondition().isPresent());
assertEquals(documentCollection, query.getDocumentCollection());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameGte.
@Test
public void shouldSelectWhereNameGte() {
String documentCollection = "documentCollection";
Number value = 10;
DocumentDeleteQuery query = delete().from(documentCollection).where("name").gte(value).build();
DocumentCondition condition = query.getCondition().get();
Document document = condition.getDocument();
assertTrue(query.getDocuments().isEmpty());
assertEquals(documentCollection, query.getDocumentCollection());
assertEquals(Condition.GREATER_EQUALS_THAN, condition.getCondition());
assertEquals("name", document.getName());
assertEquals(value, document.get());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameGt.
@Test
public void shouldSelectWhereNameGt() {
String documentCollection = "documentCollection";
Number value = 10;
DocumentDeleteQuery query = delete().from(documentCollection).where("name").gt(value).build();
DocumentCondition condition = query.getCondition().get();
Document document = condition.getDocument();
assertTrue(query.getDocuments().isEmpty());
assertEquals(documentCollection, query.getDocumentCollection());
assertEquals(Condition.GREATER_THAN, condition.getCondition());
assertEquals("name", document.getName());
assertEquals(value, document.get());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameAnd.
@Test
public void shouldSelectWhereNameAnd() {
String documentCollection = "documentCollection";
String name = "Ada Lovelace";
DocumentDeleteQuery query = delete().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 org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class ArangoDBDocumentCollectionManagerTest method shouldRemoveEntity2.
@Test
public void shouldRemoveEntity2() {
DocumentEntity documentEntity = entityManager.insert(getEntity());
Document id = documentEntity.find("name").get();
DocumentQuery select = select().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
entityManager.delete(deleteQuery);
assertTrue(entityManager.select(select).isEmpty());
}
Aggregations