Search in sources :

Example 1 with DocumentTemplate

use of org.jnosql.artemis.document.DocumentTemplate in project jnosql-artemis by eclipse.

the class RepositoryDocumentBean method create.

@Override
public Repository create(CreationalContext<Repository> creationalContext) {
    ClassRepresentations classRepresentations = getInstance(ClassRepresentations.class);
    DocumentTemplate repository = provider.isEmpty() ? getInstance(DocumentTemplate.class) : getInstance(DocumentTemplate.class, provider);
    Reflections reflections = getInstance(Reflections.class);
    Converters converters = getInstance(Converters.class);
    DocumentRepositoryProxy handler = new DocumentRepositoryProxy(repository, classRepresentations, type, reflections, converters);
    return (Repository) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, handler);
}
Also used : Repository(org.jnosql.artemis.Repository) Converters(org.jnosql.artemis.Converters) DocumentTemplate(org.jnosql.artemis.document.DocumentTemplate) ClassRepresentations(org.jnosql.artemis.reflection.ClassRepresentations) Reflections(org.jnosql.artemis.reflection.Reflections)

Example 2 with DocumentTemplate

use of org.jnosql.artemis.document.DocumentTemplate in project jnosql-artemis by eclipse.

the class MockProducer method getDocumentRepository.

@Produces
@Database(value = DatabaseType.DOCUMENT, provider = "documentRepositoryMock")
public DocumentTemplate getDocumentRepository() {
    DocumentTemplate documentTemplate = mock(DocumentTemplate.class);
    when(documentTemplate.insert(Mockito.any(Person.class))).thenReturn(Person.builder().withName("documentRepositoryMock").build());
    when(documentTemplate.singleResult(any(DocumentQuery.class))).thenReturn(Optional.empty());
    when(documentTemplate.find(eq(Person.class), Mockito.any())).thenReturn(Optional.empty());
    return documentTemplate;
}
Also used : DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) DocumentTemplate(org.jnosql.artemis.document.DocumentTemplate) Person(org.jnosql.artemis.model.Person) Produces(javax.enterprise.inject.Produces)

Aggregations

DocumentTemplate (org.jnosql.artemis.document.DocumentTemplate)2 Produces (javax.enterprise.inject.Produces)1 Converters (org.jnosql.artemis.Converters)1 Repository (org.jnosql.artemis.Repository)1 Person (org.jnosql.artemis.model.Person)1 ClassRepresentations (org.jnosql.artemis.reflection.ClassRepresentations)1 Reflections (org.jnosql.artemis.reflection.Reflections)1 DocumentQuery (org.jnosql.diana.api.document.DocumentQuery)1