use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class DocumentQueryDeleteParserTest method shouldDeleteByNameAndAge.
@Test
public void shouldDeleteByNameAndAge() {
DocumentDeleteQuery query = parser.parse("deleteByNameAndAge", new Object[] { "name", 10 }, classRepresentation, converters);
DocumentCondition condition = query.getCondition().get();
assertEquals("Person", query.getDocumentCollection());
assertEquals(Condition.AND, condition.getCondition());
List<DocumentCondition> conditions = condition.getDocument().get(new TypeReference<List<DocumentCondition>>() {
});
DocumentCondition condition1 = conditions.get(0);
assertEquals(Condition.EQUALS, condition1.getCondition());
assertEquals(Document.of("name", "name"), condition1.getDocument());
DocumentCondition condition2 = conditions.get(1);
assertEquals(Condition.EQUALS, condition2.getCondition());
assertEquals(Document.of("age", 10), condition2.getDocument());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class DocumentQueryDeleteParserTest method shouldDeleteByAgeLessThanEqual.
@Test
public void shouldDeleteByAgeLessThanEqual() {
DocumentDeleteQuery query = parser.parse("deleteByAgeLessThanEqual", new Object[] { 10 }, classRepresentation, converters);
assertEquals("Person", query.getDocumentCollection());
assertEquals(Condition.LESSER_EQUALS_THAN, query.getCondition().get().getCondition());
assertEquals(Document.of("age", 10), query.getCondition().get().getDocument());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class DocumentQueryDeleteParserTest method shouldDeleteByAgeGreaterThan.
@Test
public void shouldDeleteByAgeGreaterThan() {
DocumentDeleteQuery query = parser.parse("deleteByAgeGreaterThan", new Object[] { 10 }, classRepresentation, converters);
assertEquals("Person", query.getDocumentCollection());
assertEquals(Condition.GREATER_THAN, query.getCondition().get().getCondition());
assertEquals(Document.of("age", 10), query.getCondition().get().getDocument());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class DocumentQueryDeleteParserTest method shouldDeleteByAgeLessThan.
@Test
public void shouldDeleteByAgeLessThan() {
DocumentDeleteQuery query = parser.parse("deleteByAgeLessThan", new Object[] { 10 }, classRepresentation, converters);
assertEquals("Person", query.getDocumentCollection());
assertEquals(Condition.LESSER_THAN, query.getCondition().get().getCondition());
assertEquals(Document.of("age", 10), query.getCondition().get().getDocument());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.
the class DocumentRepositoryAsyncProxyTest method shouldDeleteByNameCallBack.
@Test
public void shouldDeleteByNameCallBack() {
ArgumentCaptor<DocumentDeleteQuery> captor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
ArgumentCaptor<Consumer> consumerCaptor = ArgumentCaptor.forClass(Consumer.class);
Consumer<Void> voidConsumer = v -> {
};
personRepository.deleteByName("name", voidConsumer);
verify(template).delete(captor.capture(), consumerCaptor.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());
assertEquals(voidConsumer, consumerCaptor.getValue());
}
Aggregations