use of org.jnosql.diana.api.document.DocumentCondition in project jnosql-artemis by eclipse.
the class AbstractMapperQuery method likeImpl.
protected void likeImpl(String value) {
requireNonNull(value, "value is required");
DocumentCondition newCondition = DocumentCondition.like(Document.of(representation.getColumnField(name), getValue(value)));
appendCondition(newCondition);
}
use of org.jnosql.diana.api.document.DocumentCondition 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.DocumentCondition in project jnosql-artemis by eclipse.
the class DocumentQueryParserTest method shouldFindByNameAndAAgeBetween.
@Test
public void shouldFindByNameAndAAgeBetween() {
DocumentQuery query = parser.parse("findByNameAndAgeBetween", new Object[] { "name", 10, 11 }, classRepresentation, converters);
assertEquals("Person", query.getDocumentCollection());
DocumentCondition condition = query.getCondition().get();
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.BETWEEN, condition2.getCondition());
assertEquals(Document.of("age", Arrays.asList(10, 11)), condition2.getDocument());
}
use of org.jnosql.diana.api.document.DocumentCondition 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());
}
use of org.jnosql.diana.api.document.DocumentCondition in project jnosql-artemis by eclipse.
the class DocumentRepositoryProxyTest method shouldFindByAgeLessEqual.
@Test
public void shouldFindByAgeLessEqual() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(DocumentQuery.class))).thenReturn(singletonList(ada));
personRepository.findByAgeLessThan(33);
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
verify(template).select(captor.capture());
DocumentQuery query = captor.getValue();
DocumentCondition condition = query.getCondition().get();
assertEquals("Person", query.getDocumentCollection());
assertEquals(LESSER_THAN, condition.getCondition());
assertEquals(Document.of("age", 33), condition.getDocument());
}
Aggregations