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