Search in sources :

Example 1 with DocumentCollectionManager

use of jakarta.nosql.document.DocumentCollectionManager in project jnosql-diana by eclipse.

the class DefaultSelectQueryBuilderTest method shouldExecuteSingleResultManager.

@Test
public void shouldExecuteSingleResultManager() {
    DocumentCollectionManager manager = Mockito.mock(DocumentCollectionManager.class);
    ArgumentCaptor<DocumentQuery> queryCaptor = ArgumentCaptor.forClass(DocumentQuery.class);
    String collection = "collection";
    Optional<DocumentEntity> entities = select().from(collection).getSingleResult(manager);
    Mockito.verify(manager).singleResult(queryCaptor.capture());
    checkQuery(queryCaptor, collection);
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) DocumentEntity(jakarta.nosql.document.DocumentEntity) DocumentCollectionManager(jakarta.nosql.document.DocumentCollectionManager) Test(org.junit.jupiter.api.Test)

Example 2 with DocumentCollectionManager

use of jakarta.nosql.document.DocumentCollectionManager in project jnosql-diana by eclipse.

the class TemplateBean method create.

@Override
public DocumentTemplate create(CreationalContext<DocumentTemplate> creationalContext) {
    DocumentTemplateProducer producer = getInstance(DocumentTemplateProducer.class);
    DocumentCollectionManager manager = getManager();
    return producer.get(manager);
}
Also used : DocumentCollectionManager(jakarta.nosql.document.DocumentCollectionManager) DocumentTemplateProducer(jakarta.nosql.mapping.document.DocumentTemplateProducer)

Example 3 with DocumentCollectionManager

use of jakarta.nosql.document.DocumentCollectionManager in project jnosql-diana by eclipse.

the class DocumentTemplateConverter method success.

@Override
public DocumentTemplate success(String value) {
    Config config = BeanManagers.getInstance(Config.class);
    final DocumentCollectionManager manager = config.getValue(value, DocumentCollectionManager.class);
    DocumentTemplateProducer producer = BeanManagers.getInstance(DocumentTemplateProducer.class);
    return producer.get(manager);
}
Also used : Config(org.eclipse.microprofile.config.Config) DocumentCollectionManager(jakarta.nosql.document.DocumentCollectionManager) DocumentTemplateProducer(jakarta.nosql.mapping.document.DocumentTemplateProducer)

Example 4 with DocumentCollectionManager

use of jakarta.nosql.document.DocumentCollectionManager in project jnosql-diana by eclipse.

the class MockProducer method getDocumentCollectionManager.

@Produces
public DocumentCollectionManager getDocumentCollectionManager() {
    DocumentEntity entity = DocumentEntity.of("Person");
    entity.add(Document.of("name", "Default"));
    entity.add(Document.of("age", 10));
    DocumentCollectionManager manager = mock(DocumentCollectionManager.class);
    when(manager.insert(Mockito.any(DocumentEntity.class))).thenReturn(entity);
    return manager;
}
Also used : DocumentEntity(jakarta.nosql.document.DocumentEntity) DocumentCollectionManager(jakarta.nosql.document.DocumentCollectionManager) Produces(javax.enterprise.inject.Produces)

Example 5 with DocumentCollectionManager

use of jakarta.nosql.document.DocumentCollectionManager in project jnosql-diana by eclipse.

the class MockProducer method getDocumentCollectionManagerMock.

@Produces
@Database(value = DatabaseType.DOCUMENT, provider = "documentRepositoryMock")
public DocumentCollectionManager getDocumentCollectionManagerMock() {
    DocumentEntity entity = DocumentEntity.of("Person");
    entity.add(Document.of("name", "documentRepositoryMock"));
    entity.add(Document.of("age", 10));
    DocumentCollectionManager manager = mock(DocumentCollectionManager.class);
    when(manager.insert(Mockito.any(DocumentEntity.class))).thenReturn(entity);
    when(manager.singleResult(Mockito.any(DocumentQuery.class))).thenReturn(Optional.empty());
    return manager;
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) DocumentEntity(jakarta.nosql.document.DocumentEntity) DocumentCollectionManager(jakarta.nosql.document.DocumentCollectionManager) Produces(javax.enterprise.inject.Produces) Database(jakarta.nosql.mapping.Database)

Aggregations

DocumentCollectionManager (jakarta.nosql.document.DocumentCollectionManager)17 DocumentEntity (jakarta.nosql.document.DocumentEntity)8 Test (org.junit.jupiter.api.Test)8 Produces (javax.enterprise.inject.Produces)5 DocumentQuery (jakarta.nosql.document.DocumentQuery)4 DocumentTemplateProducer (jakarta.nosql.mapping.document.DocumentTemplateProducer)3 Database (jakarta.nosql.mapping.Database)2 Document (jakarta.nosql.document.Document)1 DocumentDeleteQuery (jakarta.nosql.document.DocumentDeleteQuery)1 Pagination (jakarta.nosql.mapping.Pagination)1 DocumentEventPersistManager (jakarta.nosql.mapping.document.DocumentEventPersistManager)1 DocumentQueryPagination (jakarta.nosql.mapping.document.DocumentQueryPagination)1 DocumentTemplate (jakarta.nosql.mapping.document.DocumentTemplate)1 PersonRepository (jakarta.nosql.tck.entities.PersonRepository)1 DocumentCollectionManagerMock (org.eclipse.jnosql.mapping.document.configuration.DocumentConfigurationMock.DocumentCollectionManagerMock)1 Config (org.eclipse.microprofile.config.Config)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1