Search in sources :

Example 26 with ColumnQuery

use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.

the class DefaultColumnMapperSelectBuilderTest method shouldSelectWhereNameAnd.

@Test
public void shouldSelectWhereNameAnd() {
    ColumnQuery query = mapperBuilder.selectFrom(Person.class).where("age").between(10, 20).and("name").eq("Ada").build();
    ColumnQuery queryExpected = select().from("Person").where("age").between(10, 20).and("name").eq("Ada").build();
    assertEquals(queryExpected, query);
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 27 with ColumnQuery

use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.

the class DefaultColumnMapperSelectBuilderTest method shouldSelectStart.

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

Example 28 with ColumnQuery

use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.

the class DefaultColumnMapperSelectBuilderTest method shouldExecuteQueryPagination.

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

Example 29 with ColumnQuery

use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.

the class DefaultColumnMapperSelectBuilderTest method shouldCreatePage.

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

Example 30 with ColumnQuery

use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.

the class DefaultColumnMapperSelectBuilderTest method shouldSelectOrderDesc.

@Test
public void shouldSelectOrderDesc() {
    ColumnQuery query = mapperBuilder.selectFrom(Worker.class).orderBy("salary").desc().build();
    ColumnQuery queryExpected = select().from("Worker").orderBy("money").desc().build();
    assertEquals(queryExpected, query);
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Worker(jakarta.nosql.tck.entities.Worker) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnQuery (jakarta.nosql.column.ColumnQuery)160 Test (org.junit.jupiter.api.Test)120 ColumnCondition (jakarta.nosql.column.ColumnCondition)64 Person (jakarta.nosql.tck.entities.Person)50 Column (jakarta.nosql.column.Column)35 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)30 ValueSource (org.junit.jupiter.params.provider.ValueSource)30 Pagination (jakarta.nosql.mapping.Pagination)27 ColumnEntity (jakarta.nosql.column.ColumnEntity)26 List (java.util.List)26 Collections.singletonList (java.util.Collections.singletonList)10 Value (jakarta.nosql.Value)8 ColumnQueryPagination (jakarta.nosql.mapping.column.ColumnQueryPagination)8 Arrays.asList (java.util.Arrays.asList)8 Params (jakarta.nosql.Params)7 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)7 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)7 ColumnQueryParams (jakarta.nosql.column.ColumnQueryParams)7 ColumnTemplate (jakarta.nosql.mapping.column.ColumnTemplate)6 SelectQuery (jakarta.nosql.query.SelectQuery)6