Search in sources :

Example 11 with DocumentCollectionManager

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

the class DocumentCollectionManagerConverterTest method shouldReturnManager.

@Test
public void shouldReturnManager() {
    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 DocumentCollectionManager manager = config.getValue(prefix, DocumentCollectionManager.class);
    final DocumentCollectionManagerMock managerMock = DocumentCollectionManagerMock.class.cast(manager);
    Assertions.assertEquals("database", managerMock.getDatabase());
    System.clearProperty(prefix);
    System.clearProperty(prefix + ".settings.key");
    System.clearProperty(prefix + ".settings.key2");
    System.clearProperty(prefix + ".provider");
    System.clearProperty(prefix + ".database");
}
Also used : DocumentCollectionManager(jakarta.nosql.document.DocumentCollectionManager) DocumentCollectionManagerMock(org.eclipse.jnosql.mapping.document.configuration.DocumentConfigurationMock.DocumentCollectionManagerMock) Test(org.junit.jupiter.api.Test)

Example 12 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)

Example 13 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 14 with DocumentCollectionManager

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

the class OrientDBDocumentCollectionManagerFactoryTest method shouldCreateEntityManager.

@Test
public void shouldCreateEntityManager() {
    DocumentCollectionManager database = managerFactory.get("database");
    assertNotNull(database);
}
Also used : DocumentCollectionManager(jakarta.nosql.document.DocumentCollectionManager) Test(org.junit.jupiter.api.Test)

Example 15 with DocumentCollectionManager

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

the class ArangoDBDocumentCollectionManagerFactoryTest method shouldCreateEntityManager.

@Test
public void shouldCreateEntityManager() {
    DocumentCollectionManager database = managerFactory.get("database");
    assertNotNull(database);
}
Also used : DocumentCollectionManager(jakarta.nosql.document.DocumentCollectionManager) Test(org.junit.jupiter.api.Test)

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