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);
}
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");
}
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);
}
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);
}
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);
}
Aggregations