Search in sources :

Example 1 with DocumentTemplate

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

the class ReactiveDocumentManagerConverter method success.

@Override
protected ReactiveDocumentTemplate success(String value) {
    Config config = BeanManagers.getInstance(Config.class);
    final DocumentTemplate template = config.getValue(value, DocumentTemplate.class);
    ReactiveDocumentTemplateProducer producer = BeanManagers.getInstance(ReactiveDocumentTemplateProducer.class);
    return producer.get(template);
}
Also used : Config(org.eclipse.microprofile.config.Config) ReactiveDocumentTemplate(org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate) DocumentTemplate(jakarta.nosql.mapping.document.DocumentTemplate) ReactiveDocumentTemplateProducer(org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplateProducer)

Example 2 with DocumentTemplate

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

the class DefaultDocumentTemplateProducerTest method shouldReturn.

@Test
public void shouldReturn() {
    DocumentCollectionManager manager = Mockito.mock(DocumentCollectionManager.class);
    DocumentTemplate documentTemplate = producer.get(manager);
    assertNotNull(documentTemplate);
}
Also used : DocumentCollectionManager(jakarta.nosql.document.DocumentCollectionManager) DocumentTemplate(jakarta.nosql.mapping.document.DocumentTemplate) Test(org.junit.jupiter.api.Test)

Example 3 with DocumentTemplate

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

use of jakarta.nosql.mapping.document.DocumentTemplate 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)

Example 5 with DocumentTemplate

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

the class DefaultDocumentMapperDeleteBuilderTest method shouldExecuteDelete.

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

Aggregations

DocumentTemplate (jakarta.nosql.mapping.document.DocumentTemplate)14 Test (org.junit.jupiter.api.Test)10 Person (jakarta.nosql.tck.entities.Person)6 DocumentQuery (jakarta.nosql.document.DocumentQuery)5 Pagination (jakarta.nosql.mapping.Pagination)3 DocumentQueryPagination (jakarta.nosql.mapping.document.DocumentQueryPagination)3 Converters (jakarta.nosql.mapping.Converters)2 ReactiveDocumentTemplate (org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate)2 ReactiveDocumentTemplateProducer (org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplateProducer)2 ClassMappings (org.eclipse.jnosql.mapping.reflection.ClassMappings)2 DocumentCollectionManager (jakarta.nosql.document.DocumentCollectionManager)1 DocumentDeleteQuery (jakarta.nosql.document.DocumentDeleteQuery)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