Search in sources :

Example 1 with ReactiveDocumentTemplate

use of org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate 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 ReactiveDocumentTemplate

use of org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate in project jnosql-diana by eclipse.

the class ReactiveDocumentManagerConverterTest method shouldReturnTemplate.

@Test
public void shouldReturnTemplate() {
    final String prefix = UUID.randomUUID().toString();
    System.setProperty(prefix, prefix);
    System.setProperty(prefix + ".settings.key", "value");
    System.setProperty(prefix + ".settings.key2", "value2");
    System.setProperty(prefix + ".provider", DocumentConfigurationMock.class.getName());
    System.setProperty(prefix + ".database", "database");
    final ReactiveDocumentTemplate template = config.getValue(prefix, ReactiveDocumentTemplate.class);
    Assertions.assertNotNull(template);
    System.clearProperty(prefix);
    System.clearProperty(prefix + ".settings.key");
    System.clearProperty(prefix + ".settings.key2");
    System.clearProperty(prefix + ".provider");
    System.clearProperty(prefix + ".database");
}
Also used : ReactiveDocumentTemplate(org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate) Test(org.junit.jupiter.api.Test)

Example 3 with ReactiveDocumentTemplate

use of org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate in project jnosql-diana by eclipse.

the class DocumentReactiveRepositoryProxyTest method setUp.

@BeforeEach
public void setUp() {
    this.template = Mockito.mock(DocumentTemplate.class);
    final ReactiveDocumentTemplate reactiveTemplate = reactiveProducer.get(template);
    ReactiveDocumentRepositoryProxy<?> personHandler = new ReactiveDocumentRepositoryProxy<>(reactiveTemplate, template, converters, classMappings, PersonRepository.class);
    when(template.insert(any(Person.class))).thenReturn(Person.builder().build());
    when(template.insert(any(Person.class), any(Duration.class))).thenReturn(Person.builder().build());
    when(template.update(any(Person.class))).thenReturn(Person.builder().build());
    personRepository = (PersonRepository) Proxy.newProxyInstance(PersonRepository.class.getClassLoader(), new Class[] { PersonRepository.class }, personHandler);
}
Also used : ReactiveDocumentTemplate(org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate) ReactiveDocumentTemplate(org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate) DocumentTemplate(jakarta.nosql.mapping.document.DocumentTemplate) Duration(java.time.Duration) Person(jakarta.nosql.tck.entities.Person) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ReactiveDocumentTemplate

use of org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate in project jnosql-diana by eclipse.

the class DefaultReactiveDocumentRepositoryProducer method get.

@Override
public <T, K, R extends ReactiveRepository<T, K>> R get(Class<R> repositoryClass, DocumentTemplate template) {
    Objects.requireNonNull(template, "template is required");
    Objects.requireNonNull(repositoryClass, "repositoryClass is required");
    final ReactiveDocumentTemplate reactiveTemplate = producerReactive.get(template);
    ReactiveDocumentRepositoryProxy<R> handler = new ReactiveDocumentRepositoryProxy<>(reactiveTemplate, template, converters, classMappings, repositoryClass);
    return (R) Proxy.newProxyInstance(repositoryClass.getClassLoader(), new Class[] { repositoryClass }, handler);
}
Also used : ReactiveDocumentTemplate(org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate)

Example 5 with ReactiveDocumentTemplate

use of org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate 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)

Aggregations

ReactiveDocumentTemplate (org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplate)5 DocumentTemplate (jakarta.nosql.mapping.document.DocumentTemplate)3 ReactiveDocumentTemplateProducer (org.eclipse.jnosql.mapping.document.reactive.ReactiveDocumentTemplateProducer)2 Converters (jakarta.nosql.mapping.Converters)1 Person (jakarta.nosql.tck.entities.Person)1 Duration (java.time.Duration)1 ReactiveRepository (org.eclipse.jnosql.mapping.reactive.ReactiveRepository)1 ClassMappings (org.eclipse.jnosql.mapping.reflection.ClassMappings)1 Config (org.eclipse.microprofile.config.Config)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1