use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class DocumentRepositoryAsyncProxyTest method shouldDeleteByName.
@Test
public void shouldDeleteByName() {
ArgumentCaptor<DocumentDeleteQuery> captor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
personRepository.deleteByName("name");
verify(template).delete(captor.capture());
DocumentDeleteQuery query = captor.getValue();
DocumentCondition condition = query.getCondition().get();
assertEquals("Person", query.getDocumentCollection());
assertEquals(Condition.EQUALS, condition.getCondition());
assertEquals(Document.of("name", "name"), condition.getDocument());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class DocumentRepositoryAsyncProxyTest method shouldExecuteDeleteQuery.
//
@Test
public void shouldExecuteDeleteQuery() {
ArgumentCaptor<DocumentDeleteQuery> captor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
DocumentDeleteQuery deleteQuery = delete().from("Person").where("name").eq("Ada").build();
personRepository.deleteQuery(deleteQuery);
verify(template).delete(captor.capture());
assertEquals(deleteQuery, captor.getValue());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class AbstractDocumentRepositoryAsyncProxy method invoke.
@Override
public Object invoke(Object instance, Method method, Object[] args) throws Throwable {
String methodName = method.getName();
DocumentRepositoryType type = DocumentRepositoryType.of(method, args);
switch(type) {
case DEFAULT:
return method.invoke(getRepository(), args);
case FIND_BY:
DocumentQuery query = getQueryParser().parse(methodName, args, getClassRepresentation(), getConverters());
return executeQuery(getCallBack(args), query);
case FIND_ALL:
return executeQuery(getCallBack(args), select().from(getClassRepresentation().getName()).build());
case DELETE_BY:
DocumentDeleteQuery deleteQuery = getDeleteParser().parse(methodName, args, getClassRepresentation(), getConverters());
return executeDelete(args, deleteQuery);
case QUERY:
DocumentQuery documentQuery = getQuery(args).get();
return executeQuery(getCallBack(args), documentQuery);
case QUERY_DELETE:
return executeDelete(args, getDeleteQuery(args).get());
case OBJECT_METHOD:
return method.invoke(this, args);
default:
return Void.class;
}
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class AbstractDocumentRepositoryProxy method invoke.
@Override
public Object invoke(Object instance, Method method, Object[] args) throws Throwable {
String methodName = method.getName();
DocumentRepositoryType type = DocumentRepositoryType.of(method, args);
Class<?> typeClass = getClassRepresentation().getClassInstance();
switch(type) {
case DEFAULT:
return method.invoke(getRepository(), args);
case FIND_BY:
DocumentQuery query = getQueryParser().parse(methodName, args, getClassRepresentation(), getConverters());
return returnObject(query, getTemplate(), typeClass, method);
case FIND_ALL:
return returnObject(select().from(getClassRepresentation().getName()).build(), getTemplate(), typeClass, method);
case DELETE_BY:
getTemplate().delete(getDeleteParser().parse(methodName, args, getClassRepresentation(), getConverters()));
return null;
case QUERY:
DocumentQuery documentQuery = getQuery(args).get();
return returnObject(documentQuery, getTemplate(), typeClass, method);
case QUERY_DELETE:
DocumentDeleteQuery deleteQuery = getDeleteQuery(args).get();
getTemplate().delete(deleteQuery);
return Void.class;
case OBJECT_METHOD:
return method.invoke(this, args);
default:
return Void.class;
}
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class DocumentRepositoryProxyTest method shouldDeleteQuery.
@Test
public void shouldDeleteQuery() {
ArgumentCaptor<DocumentDeleteQuery> captor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
DocumentDeleteQuery query = delete().from("Person").where("name").eq("Ada").build();
personRepository.deleteQuery(query);
verify(template).delete(captor.capture());
assertEquals(query, captor.getValue());
}
Aggregations