use of jakarta.nosql.document.DocumentCondition in project jnosql-diana by eclipse.
the class DocumentRepositoryProxyPaginationTest method shouldFindByIn.
@Test
public void shouldFindByIn() {
Vendor vendor = new Vendor("vendor");
vendor.setPrefixes(Collections.singleton("prefix"));
when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(vendor));
Pagination pagination = getPagination();
vendorRepository.findByPrefixesIn(Collections.singletonList("prefix"), pagination);
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
verify(template).singleResult(captor.capture());
DocumentQuery query = captor.getValue();
DocumentCondition condition = query.getCondition().get();
assertEquals("vendors", query.getDocumentCollection());
assertEquals(IN, condition.getCondition());
assertEquals(pagination.getSkip(), query.getSkip());
assertEquals(pagination.getLimit(), query.getLimit());
}
use of jakarta.nosql.document.DocumentCondition in project jnosql-diana by eclipse.
the class DocumentRepositoryProxyPaginationTest method shouldFindByGreaterThan.
@Test
public void shouldFindByGreaterThan() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(ada));
Pagination pagination = getPagination();
personRepository.findByAgeGreaterThan(33, pagination);
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(GREATER_THAN, condition.getCondition());
assertEquals(Document.of("age", 33), condition.getDocument());
assertEquals(pagination.getSkip(), query.getSkip());
assertEquals(pagination.getLimit(), query.getLimit());
}
use of jakarta.nosql.document.DocumentCondition in project jnosql-diana by eclipse.
the class DocumentRepositoryProxyPaginationTest method shouldFindByAgeLessThanEqual.
@Test
public void shouldFindByAgeLessThanEqual() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(ada));
Pagination pagination = getPagination();
personRepository.findByAgeLessThanEqual(33, pagination);
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_EQUALS_THAN, condition.getCondition());
assertEquals(Document.of("age", 33), condition.getDocument());
assertEquals(pagination.getSkip(), query.getSkip());
assertEquals(pagination.getLimit(), query.getLimit());
}
use of jakarta.nosql.document.DocumentCondition in project jnosql-diana by eclipse.
the class DocumentRepositoryProxyTest method shouldFindByIn.
@Test
public void shouldFindByIn() {
Vendor vendor = new Vendor("vendor");
vendor.setPrefixes(Collections.singleton("prefix"));
when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(vendor));
vendorRepository.findByPrefixesIn(singletonList("prefix"));
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
verify(template).singleResult(captor.capture());
DocumentQuery query = captor.getValue();
DocumentCondition condition = query.getCondition().get();
assertEquals("vendors", query.getDocumentCollection());
assertEquals(IN, condition.getCondition());
}
use of jakarta.nosql.document.DocumentCondition 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());
}
Aggregations