Search in sources :

Example 1 with ColumnTemplate

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

the class DefaultColumnMapperDeleteBuilderTest method shouldExecuteDeleteFrom.

@Test
public void shouldExecuteDeleteFrom() {
    ColumnTemplate template = Mockito.mock(ColumnTemplate.class);
    ArgumentCaptor<ColumnDeleteQuery> queryCaptor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
    mapperBuilder.deleteFrom(Person.class).delete(template);
    Mockito.verify(template).delete(queryCaptor.capture());
    ColumnDeleteQuery query = queryCaptor.getValue();
    ColumnDeleteQuery queryExpected = delete().from("Person").build();
    assertEquals(queryExpected, query);
}
Also used : ColumnTemplate(jakarta.nosql.mapping.column.ColumnTemplate) Person(jakarta.nosql.tck.entities.Person) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 2 with ColumnTemplate

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

the class DefaultColumnMapperSelectBuilderTest method shouldExecuteSingleQueryPagination.

@Test
public void shouldExecuteSingleQueryPagination() {
    Pagination pagination = Pagination.page(2).size(2);
    ColumnTemplate template = Mockito.mock(ColumnTemplate.class);
    ArgumentCaptor<ColumnQuery> queryCaptor = ArgumentCaptor.forClass(ColumnQuery.class);
    mapperBuilder.selectFrom(Person.class).getSingleResult(template, pagination);
    Mockito.verify(template).singleResult(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 3 with ColumnTemplate

use of jakarta.nosql.mapping.column.ColumnTemplate 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 4 with ColumnTemplate

use of jakarta.nosql.mapping.column.ColumnTemplate 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 5 with ColumnTemplate

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

the class DefaultColumnMapperSelectBuilderTest method shouldExecuteQuery.

@Test
public void shouldExecuteQuery() {
    ColumnTemplate template = Mockito.mock(ColumnTemplate.class);
    ArgumentCaptor<ColumnQuery> queryCaptor = ArgumentCaptor.forClass(ColumnQuery.class);
    mapperBuilder.selectFrom(Person.class).getResult(template);
    Mockito.verify(template).select(queryCaptor.capture());
    ColumnQuery query = queryCaptor.getValue();
    ColumnQuery queryExpected = select().from("Person").build();
    assertEquals(queryExpected, query);
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnTemplate(jakarta.nosql.mapping.column.ColumnTemplate) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnTemplate (jakarta.nosql.mapping.column.ColumnTemplate)14 Test (org.junit.jupiter.api.Test)10 Person (jakarta.nosql.tck.entities.Person)6 ColumnQuery (jakarta.nosql.column.ColumnQuery)5 Pagination (jakarta.nosql.mapping.Pagination)3 ColumnQueryPagination (jakarta.nosql.mapping.column.ColumnQueryPagination)3 Converters (jakarta.nosql.mapping.Converters)2 ReactiveColumnTemplate (org.eclipse.jnosql.mapping.column.reactive.ReactiveColumnTemplate)2 ReactiveColumnTemplateProducer (org.eclipse.jnosql.mapping.column.reactive.ReactiveColumnTemplateProducer)2 ClassMappings (org.eclipse.jnosql.mapping.reflection.ClassMappings)2 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)1 ColumnFamilyManager (jakarta.nosql.column.ColumnFamilyManager)1 Repository (jakarta.nosql.mapping.Repository)1 PersonRepository (jakarta.nosql.tck.entities.PersonRepository)1 ReactiveRepository (org.eclipse.jnosql.mapping.reactive.ReactiveRepository)1 Config (org.eclipse.microprofile.config.Config)1