use of jakarta.nosql.document.DocumentQuery in project jnosql-diana 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(Stream.of(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());
}
use of jakarta.nosql.document.DocumentQuery in project jnosql-diana by eclipse.
the class DocumentRepositoryProxyTest method shouldFindByNameLike.
@Test
public void shouldFindByNameLike() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(ada));
personRepository.findByNameLike("Ada");
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(LIKE, condition.getCondition());
assertEquals(Document.of("name", "Ada"), condition.getDocument());
}
use of jakarta.nosql.document.DocumentQuery in project jnosql-diana by eclipse.
the class DefaultDocumentEventPersistManagerTest method shouldFirePreQuery.
@Test
public void shouldFirePreQuery() {
DocumentQuery query = DocumentQuery.select().from("collection").build();
subject.firePreQuery(query);
ArgumentCaptor<DocumentQueryExecute> captor = ArgumentCaptor.forClass(DocumentQueryExecute.class);
verify(documentQueryExecute).fire(captor.capture());
assertEquals(query, captor.getValue().getQuery());
}
use of jakarta.nosql.document.DocumentQuery in project jnosql-diana by eclipse.
the class DefaultDocumentMapperSelectBuilderTest method shouldSelectOrderAsc.
@Test
public void shouldSelectOrderAsc() {
DocumentQuery query = mapperBuilder.selectFrom(Worker.class).orderBy("salary").asc().build();
DocumentQuery queryExpected = select().from("Worker").orderBy("money").asc().build();
assertEquals(queryExpected, query);
}
use of jakarta.nosql.document.DocumentQuery in project jnosql-diana by eclipse.
the class DefaultDocumentMapperSelectBuilderTest method shouldCreateQueryWithPagination.
@Test
public void shouldCreateQueryWithPagination() {
Pagination pagination = Pagination.page(2).size(2);
DocumentMapperFrom columnFrom = mapperBuilder.selectFrom(Person.class);
DocumentQuery query = columnFrom.build(pagination);
assertEquals(pagination.getLimit(), query.getLimit());
assertEquals(pagination.getSkip(), query.getSkip());
}
Aggregations