use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class DefaultDocumentTemplateAsyncTest method shouldDeleteCallBack.
@Test
public void shouldDeleteCallBack() {
DocumentDeleteQuery query = delete().from("delete").build();
Consumer<Void> callback = v -> {
};
subject.delete(query, callback);
verify(managerMock).delete(query, callback);
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class DefaultDocumentTemplateAsyncTest method shouldDeleteByEntityCallBack.
@Test
public void shouldDeleteByEntityCallBack() {
Consumer<Void> callback = v -> {
};
subject.delete(Person.class, 10L, callback);
ArgumentCaptor<DocumentDeleteQuery> queryCaptor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
verify(managerMock).delete(queryCaptor.capture(), Mockito.eq(callback));
DocumentDeleteQuery query = queryCaptor.getValue();
assertEquals("Person", query.getDocumentCollection());
assertEquals(DocumentCondition.eq(Document.of("_id", 10L)), query.getCondition().get());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class AbstractDocumentTemplate method delete.
@Override
public <T, ID> void delete(Class<T> entityClass, ID id) {
requireNonNull(entityClass, "entityClass is required");
requireNonNull(id, "id is required");
ClassRepresentation classRepresentation = getClassRepresentations().get(entityClass);
FieldRepresentation idField = classRepresentation.getId().orElseThrow(() -> IdNotFoundException.newInstance(entityClass));
Object value = ConverterUtil.getValue(id, classRepresentation, idField.getFieldName(), getConverters());
DocumentDeleteQuery query = DocumentQueryBuilder.delete().from(classRepresentation.getName()).where(idField.getName()).eq(value).build();
delete(query);
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class AbstractDocumentTemplateAsync method delete.
@Override
public <T, ID> void delete(Class<T> entityClass, ID id, Consumer<Void> callBack) {
requireNonNull(entityClass, "entityClass is required");
requireNonNull(id, "id is required");
requireNonNull(callBack, "callBack is required");
DocumentDeleteQuery query = getDeleteQuery(entityClass, id);
delete(query, callBack);
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class AbstractDocumentTemplateAsync method delete.
@Override
public <T, ID> void delete(Class<T> entityClass, ID id) {
requireNonNull(entityClass, "entityClass is required");
requireNonNull(id, "id is required");
DocumentDeleteQuery query = getDeleteQuery(entityClass, id);
delete(query);
}
Aggregations