use of org.jnosql.diana.api.document.DocumentCondition in project jnosql-artemis by eclipse.
the class DocumentQueryDeleteParserTest method shouldDeleteByNameAndAAgeBetween.
@Test
public void shouldDeleteByNameAndAAgeBetween() {
DocumentDeleteQuery query = parser.parse("deleteByNameAndAgeBetween", 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 DocumentQueryParserTest method shouldFindByNameOrAge.
@Test
public void shouldFindByNameOrAge() {
DocumentQuery query = parser.parse("findByNameOrAge", new Object[] { "name", 10 }, classRepresentation, converters);
DocumentCondition condition = query.getCondition().get();
assertEquals("Person", query.getDocumentCollection());
assertEquals(Condition.OR, 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 shouldFindByNameAndAge.
@Test
public void shouldFindByNameAndAge() {
DocumentQuery query = parser.parse("findByNameAndAge", 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 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.DocumentCondition in project jnosql-artemis by eclipse.
the class DocumentRepositoryAsyncProxyTest method shoudFindByNameSort.
@Test
public void shoudFindByNameSort() {
Consumer<List<Person>> callback = v -> {
};
Sort sort = Sort.of("age", Sort.SortType.ASC);
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
ArgumentCaptor<Consumer> consumerCaptor = ArgumentCaptor.forClass(Consumer.class);
personRepository.findByName("name", sort, callback);
verify(template).select(captor.capture(), consumerCaptor.capture());
DocumentQuery 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(callback, consumerCaptor.getValue());
assertEquals(sort, query.getSorts().get(0));
}
Aggregations