Search in sources :

Example 11 with DocumentTemplate

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

the class DefaultDocumentMapperSelectBuilderTest method shouldCreatePage.

@Test
public void shouldCreatePage() {
    Pagination pagination = Pagination.page(2).size(2);
    DocumentTemplate template = Mockito.mock(DocumentTemplate.class);
    ArgumentCaptor<DocumentQueryPagination> queryCaptor = ArgumentCaptor.forClass(DocumentQueryPagination.class);
    Page<Person> page = mapperBuilder.selectFrom(Person.class).page(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) DocumentQueryPagination(jakarta.nosql.mapping.document.DocumentQueryPagination) DocumentTemplate(jakarta.nosql.mapping.document.DocumentTemplate) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 12 with DocumentTemplate

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

the class DefaultDocumentRepositoryProducerTest method shouldCreateFromTemplate.

@Test
public void shouldCreateFromTemplate() {
    DocumentTemplate template = Mockito.mock(DocumentTemplate.class);
    PersonRepository personRepository = producer.get(PersonRepository.class, template);
    assertNotNull(personRepository);
}
Also used : PersonRepository(jakarta.nosql.tck.entities.PersonRepository) DocumentTemplate(jakarta.nosql.mapping.document.DocumentTemplate) Test(org.junit.jupiter.api.Test)

Example 13 with DocumentTemplate

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

the class ReactiveRepositoryDocumentBean method create.

@Override
public ReactiveRepository<?, ?> create(CreationalContext<ReactiveRepository<?, ?>> context) {
    ClassMappings classMappings = getInstance(ClassMappings.class);
    DocumentTemplate template = provider.isEmpty() ? getInstance(DocumentTemplate.class) : getInstance(DocumentTemplate.class, DatabaseQualifier.ofDocument(provider));
    ReactiveDocumentTemplateProducer reactiveProducer = getInstance(ReactiveDocumentTemplateProducer.class);
    final ReactiveDocumentTemplate reactiveDocumentTemplate = reactiveProducer.get(template);
    Converters converters = getInstance(Converters.class);
    ReactiveDocumentRepositoryProxy<?> handler = new ReactiveDocumentRepositoryProxy<>(reactiveDocumentTemplate, template, converters, classMappings, type);
    return (ReactiveRepository<?, ?>) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, handler);
}
Also used : ReactiveRepository(org.eclipse.jnosql.mapping.reactive.ReactiveRepository) ReactiveDocumentTemplate(org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate) Converters(jakarta.nosql.mapping.Converters) ReactiveDocumentTemplate(org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate) DocumentTemplate(jakarta.nosql.mapping.document.DocumentTemplate) ReactiveDocumentTemplateProducer(org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplateProducer) ClassMappings(org.eclipse.jnosql.mapping.reflection.ClassMappings)

Example 14 with DocumentTemplate

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

the class DefaultReactiveDocumentTemplateProducerTest method shouldReturnTemplate.

@Test
public void shouldReturnTemplate() {
    final DocumentTemplate template = Mockito.mock(DocumentTemplate.class);
    final ReactiveDocumentTemplate reactiveTemplate = producer.get(template);
    assertNotNull(reactiveTemplate);
}
Also used : DocumentTemplate(jakarta.nosql.mapping.document.DocumentTemplate) 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