Search in sources :

Example 51 with DocumentQuery

use of jakarta.nosql.document.DocumentQuery in project jnosql-diana by eclipse.

the class DefaultDocumentMapperSelectBuilderTest method shouldSelectWhereNameLte.

@Test
public void shouldSelectWhereNameLte() {
    DocumentQuery query = mapperBuilder.selectFrom(Person.class).where("id").lte(10).build();
    DocumentQuery queryExpected = select().from("Person").where("_id").lte(10L).build();
    assertEquals(queryExpected, query);
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 52 with DocumentQuery

use of jakarta.nosql.document.DocumentQuery in project jnosql-diana by eclipse.

the class DefaultDocumentMapperSelectBuilderTest method shouldExecuteQueryPagination.

@Test
public void shouldExecuteQueryPagination() {
    Pagination pagination = Pagination.page(2).size(2);
    DocumentTemplate template = Mockito.mock(DocumentTemplate.class);
    ArgumentCaptor<DocumentQuery> queryCaptor = ArgumentCaptor.forClass(DocumentQuery.class);
    mapperBuilder.selectFrom(Person.class).getResult(template, pagination);
    Mockito.verify(template).select(queryCaptor.capture());
    DocumentQuery query = queryCaptor.getValue();
    assertEquals(pagination.getLimit(), query.getLimit());
    assertEquals(pagination.getSkip(), query.getSkip());
}
Also used : DocumentQueryPagination(jakarta.nosql.mapping.document.DocumentQueryPagination) Pagination(jakarta.nosql.mapping.Pagination) DocumentQuery(jakarta.nosql.document.DocumentQuery) DocumentTemplate(jakarta.nosql.mapping.document.DocumentTemplate) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 53 with DocumentQuery

use of jakarta.nosql.document.DocumentQuery in project jnosql-diana by eclipse.

the class DefaultDocumentMapperSelectBuilderTest method shouldSelectStart.

@Test
public void shouldSelectStart() {
    DocumentQuery query = mapperBuilder.selectFrom(Worker.class).skip(10).build();
    DocumentQuery queryExpected = select().from("Worker").skip(10L).build();
    assertEquals(queryExpected, query);
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) Test(org.junit.jupiter.api.Test)

Example 54 with DocumentQuery

use of jakarta.nosql.document.DocumentQuery in project jnosql-diana by eclipse.

the class DefaultDocumentMapperSelectBuilderTest method shouldSelectWhereNameEq.

@Test
public void shouldSelectWhereNameEq() {
    DocumentQuery query = mapperBuilder.selectFrom(Person.class).where("name").eq("Ada").build();
    DocumentQuery queryExpected = select().from("Person").where("name").eq("Ada").build();
    assertEquals(queryExpected, query);
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 55 with DocumentQuery

use of jakarta.nosql.document.DocumentQuery in project jnosql-diana by eclipse.

the class DefaultDocumentMapperSelectBuilderTest method shouldExecuteSingleQueryPagination.

@Test
public void shouldExecuteSingleQueryPagination() {
    Pagination pagination = Pagination.page(2).size(2);
    DocumentTemplate template = Mockito.mock(DocumentTemplate.class);
    ArgumentCaptor<DocumentQuery> queryCaptor = ArgumentCaptor.forClass(DocumentQuery.class);
    mapperBuilder.selectFrom(Person.class).getSingleResult(template, pagination);
    Mockito.verify(template).singleResult(queryCaptor.capture());
    DocumentQuery query = queryCaptor.getValue();
    assertEquals(pagination.getLimit(), query.getLimit());
    assertEquals(pagination.getSkip(), query.getSkip());
}
Also used : DocumentQueryPagination(jakarta.nosql.mapping.document.DocumentQueryPagination) Pagination(jakarta.nosql.mapping.Pagination) DocumentQuery(jakarta.nosql.document.DocumentQuery) DocumentTemplate(jakarta.nosql.mapping.document.DocumentTemplate) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Aggregations

DocumentQuery (jakarta.nosql.document.DocumentQuery)292 Test (org.junit.jupiter.api.Test)234 DocumentEntity (jakarta.nosql.document.DocumentEntity)123 Document (jakarta.nosql.document.Document)98 DocumentCondition (jakarta.nosql.document.DocumentCondition)64 DocumentDeleteQuery (jakarta.nosql.document.DocumentDeleteQuery)55 Person (jakarta.nosql.tck.entities.Person)50 List (java.util.List)50 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)44 Arrays.asList (java.util.Arrays.asList)34 ValueSource (org.junit.jupiter.params.provider.ValueSource)30 Pagination (jakarta.nosql.mapping.Pagination)27 ArrayList (java.util.ArrayList)26 Collectors (java.util.stream.Collectors)19 DocumentQuery.select (jakarta.nosql.document.DocumentQuery.select)18 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)16 Matchers.contains (org.hamcrest.Matchers.contains)16 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)16 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)16 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)16