Search in sources :

Example 6 with Database

use of jakarta.nosql.mapping.Database 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 7 with Database

use of jakarta.nosql.mapping.Database in project jnosql-diana by eclipse.

the class MockProducer method getBucketManagerMock.

@Produces
@Database(value = DatabaseType.KEY_VALUE, provider = "keyvalueMock")
public BucketManager getBucketManagerMock() {
    BucketManager bucketManager = Mockito.mock(BucketManager.class);
    Person person = Person.builder().withName("keyvalueMock").build();
    when(bucketManager.get("key")).thenReturn(Optional.ofNullable(Value.of(person)));
    when(bucketManager.get(10L)).thenReturn(Optional.ofNullable(Value.of(person)));
    when(bucketManager.get("user")).thenReturn(Optional.of(Value.of(new User("keyvalueMock", "keyvalueMock", 10))));
    return bucketManager;
}
Also used : User(jakarta.nosql.tck.entities.User) BucketManager(jakarta.nosql.keyvalue.BucketManager) Person(jakarta.nosql.tck.entities.Person) Produces(javax.enterprise.inject.Produces) Database(jakarta.nosql.mapping.Database)

Example 8 with Database

use of jakarta.nosql.mapping.Database 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 9 with Database

use of jakarta.nosql.mapping.Database in project jnosql-diana by eclipse.

the class MockProducer method getColumnFamilyManagerMock.

@Produces
@Database(value = DatabaseType.COLUMN, provider = "columnRepositoryMock")
public ColumnFamilyManager getColumnFamilyManagerMock() {
    ColumnEntity entity = ColumnEntity.of("Person");
    entity.add(Column.of("name", "columnRepositoryMock"));
    entity.add(Column.of("age", 10));
    ColumnFamilyManager manager = mock(ColumnFamilyManager.class);
    when(manager.insert(Mockito.any(ColumnEntity.class))).thenReturn(entity);
    return manager;
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) Produces(javax.enterprise.inject.Produces) Database(jakarta.nosql.mapping.Database)

Example 10 with Database

use of jakarta.nosql.mapping.Database in project jnosql-diana by eclipse.

the class MockProducer method getColumnFamilyManagerMock.

@Produces
@Database(value = DatabaseType.COLUMN, provider = "columnRepositoryMock")
public ColumnFamilyManager getColumnFamilyManagerMock() {
    ColumnEntity entity = ColumnEntity.of("Person");
    entity.add(Column.of("name", "columnRepositoryMock"));
    entity.add(Column.of("age", 10));
    ColumnFamilyManager manager = mock(ColumnFamilyManager.class);
    when(manager.insert(Mockito.any(ColumnEntity.class))).thenReturn(entity);
    return manager;
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) Produces(javax.enterprise.inject.Produces) Database(jakarta.nosql.mapping.Database)

Aggregations

Database (jakarta.nosql.mapping.Database)10 Produces (javax.enterprise.inject.Produces)7 DatabaseMetadata (org.eclipse.jnosql.mapping.DatabaseMetadata)3 Test (org.junit.jupiter.api.Test)3 ColumnEntity (jakarta.nosql.column.ColumnEntity)2 ColumnFamilyManager (jakarta.nosql.column.ColumnFamilyManager)2 DocumentCollectionManager (jakarta.nosql.document.DocumentCollectionManager)2 DocumentEntity (jakarta.nosql.document.DocumentEntity)2 DocumentQuery (jakarta.nosql.document.DocumentQuery)2 BucketManager (jakarta.nosql.keyvalue.BucketManager)2 Person (jakarta.nosql.tck.entities.Person)2 User (jakarta.nosql.tck.entities.User)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Neo4jGraph (org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph)1 Graph (org.apache.tinkerpop.gremlin.structure.Graph)1 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)1