use of jakarta.nosql.mapping.document.DocumentTemplate in project jnosql-diana by eclipse.
the class DocumentTemplateConverterTest 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 DocumentTemplate template = config.getValue(prefix, DocumentTemplate.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 jakarta.nosql.mapping.document.DocumentTemplate in project jnosql-diana by eclipse.
the class DefaultDocumentRepositoryProducer method get.
@Override
public <T, K, R extends Repository<T, K>> R get(Class<R> repositoryClass, DocumentCollectionManager manager) {
Objects.requireNonNull(repositoryClass, "repository class is required");
Objects.requireNonNull(manager, "manager class is required");
DocumentTemplate template = producer.get(manager);
return get(repositoryClass, template);
}
use of jakarta.nosql.mapping.document.DocumentTemplate in project jnosql-diana by eclipse.
the class RepositoryDocumentBean method create.
@Override
public Repository create(CreationalContext<Repository> context) {
ClassMappings classMappings = getInstance(ClassMappings.class);
DocumentTemplate template = provider.isEmpty() ? getInstance(DocumentTemplate.class) : getInstance(DocumentTemplate.class, DatabaseQualifier.ofDocument(provider));
Converters converters = getInstance(Converters.class);
DocumentRepositoryProxy handler = new DocumentRepositoryProxy(template, classMappings, type, converters);
return (Repository) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, handler);
}
use of jakarta.nosql.mapping.document.DocumentTemplate in project jnosql-diana by eclipse.
the class DefaultDocumentMapperSelectBuilderTest method shouldExecuteQuery.
@Test
public void shouldExecuteQuery() {
DocumentTemplate template = Mockito.mock(DocumentTemplate.class);
ArgumentCaptor<DocumentQuery> queryCaptor = ArgumentCaptor.forClass(DocumentQuery.class);
Stream<Person> people = mapperBuilder.selectFrom(Person.class).getResult(template);
Mockito.verify(template).select(queryCaptor.capture());
DocumentQuery query = queryCaptor.getValue();
DocumentQuery queryExpected = select().from("Person").build();
assertEquals(queryExpected, query);
}
use of jakarta.nosql.mapping.document.DocumentTemplate in project jnosql-diana by eclipse.
the class DefaultDocumentMapperSelectBuilderTest method shouldExecuteSingleQuery.
@Test
public void shouldExecuteSingleQuery() {
DocumentTemplate template = Mockito.mock(DocumentTemplate.class);
ArgumentCaptor<DocumentQuery> queryCaptor = ArgumentCaptor.forClass(DocumentQuery.class);
Optional<Person> person = mapperBuilder.selectFrom(Person.class).getSingleResult(template);
Mockito.verify(template).singleResult(queryCaptor.capture());
DocumentQuery query = queryCaptor.getValue();
DocumentQuery queryExpected = select().from("Person").build();
assertEquals(queryExpected, query);
}
Aggregations