Search in sources :

Example 1 with ReactiveColumnTemplate

use of org.eclipse.jnosql.mapping.column.reactive.ReactiveColumnTemplate in project jnosql-diana by eclipse.

the class DefaultReactiveColumnRepositoryProducer method get.

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

Example 2 with ReactiveColumnTemplate

use of org.eclipse.jnosql.mapping.column.reactive.ReactiveColumnTemplate in project jnosql-diana by eclipse.

the class ReactiveColumnManagerConverter method success.

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

Example 3 with ReactiveColumnTemplate

use of org.eclipse.jnosql.mapping.column.reactive.ReactiveColumnTemplate in project jnosql-diana by eclipse.

the class ColumnReactiveRepositoryProxyTest method setUp.

@BeforeEach
public void setUp() {
    this.template = Mockito.mock(ColumnTemplate.class);
    final ReactiveColumnTemplate reactiveTemplate = reactiveProducer.get(template);
    ReactiveColumnRepositoryProxy<?> personHandler = new ReactiveColumnRepositoryProxy<>(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 : ReactiveColumnTemplate(org.eclipse.jnosql.mapping.column.reactive.ReactiveColumnTemplate) ColumnTemplate(jakarta.nosql.mapping.column.ColumnTemplate) ReactiveColumnTemplate(org.eclipse.jnosql.mapping.column.reactive.ReactiveColumnTemplate) Duration(java.time.Duration) Person(jakarta.nosql.tck.entities.Person) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ReactiveColumnTemplate

use of org.eclipse.jnosql.mapping.column.reactive.ReactiveColumnTemplate in project jnosql-diana by eclipse.

the class ReactiveRepositoryColumnBean method create.

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

Example 5 with ReactiveColumnTemplate

use of org.eclipse.jnosql.mapping.column.reactive.ReactiveColumnTemplate in project jnosql-diana by eclipse.

the class ReactiveColumnManagerConverterTest 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", ColumnConfigurationMock.class.getName());
    System.setProperty(prefix + ".database", "database");
    final ReactiveColumnTemplate template = config.getValue(prefix, ReactiveColumnTemplate.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 : ReactiveColumnTemplate(org.eclipse.jnosql.mapping.column.reactive.ReactiveColumnTemplate) Test(org.junit.jupiter.api.Test)

Aggregations

ReactiveColumnTemplate (org.eclipse.jnosql.mapping.column.reactive.ReactiveColumnTemplate)5 ColumnTemplate (jakarta.nosql.mapping.column.ColumnTemplate)3 ReactiveColumnTemplateProducer (org.eclipse.jnosql.mapping.column.reactive.ReactiveColumnTemplateProducer)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