Search in sources :

Example 1 with Database

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

the class DatabaseMetadataTest method shouldReturnToString2.

@Test
public void shouldReturnToString2() {
    Database database = Mockito.mock(Database.class);
    Mockito.when(database.value()).thenReturn(DatabaseType.COLUMN);
    DatabaseMetadata metadata = DatabaseMetadata.of(database);
    assertEquals("COLUMN", metadata.toString());
}
Also used : Database(jakarta.nosql.mapping.Database) DatabaseMetadata(org.eclipse.jnosql.mapping.DatabaseMetadata) Test(org.junit.jupiter.api.Test)

Example 2 with Database

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

the class DatabaseMetadataTest method shouldReturnToString.

@Test
public void shouldReturnToString() {
    Database database = Mockito.mock(Database.class);
    Mockito.when(database.value()).thenReturn(DatabaseType.COLUMN);
    Mockito.when(database.provider()).thenReturn("column");
    DatabaseMetadata metadata = DatabaseMetadata.of(database);
    assertEquals("COLUMN@column", metadata.toString());
}
Also used : Database(jakarta.nosql.mapping.Database) DatabaseMetadata(org.eclipse.jnosql.mapping.DatabaseMetadata) Test(org.junit.jupiter.api.Test)

Example 3 with Database

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

the class DatabaseMetadataTest method shouldReturnMetadata.

@Test
public void shouldReturnMetadata() {
    Database database = Mockito.mock(Database.class);
    Mockito.when(database.value()).thenReturn(DatabaseType.COLUMN);
    Mockito.when(database.provider()).thenReturn("column");
    DatabaseMetadata metadata = DatabaseMetadata.of(database);
    assertEquals(DatabaseType.COLUMN, metadata.getType());
    assertEquals("column", metadata.getProvider());
}
Also used : Database(jakarta.nosql.mapping.Database) DatabaseMetadata(org.eclipse.jnosql.mapping.DatabaseMetadata) Test(org.junit.jupiter.api.Test)

Example 4 with Database

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

the class GraphProducer method getGraphMock.

@Produces
@ApplicationScoped
@Database(value = DatabaseType.GRAPH, provider = "graphRepositoryMock")
public Graph getGraphMock() {
    Graph graphMock = mock(Graph.class);
    Vertex vertex = mock(Vertex.class);
    when(vertex.label()).thenReturn("Person");
    when(vertex.id()).thenReturn(10L);
    when(graphMock.vertices(10L)).thenReturn(Collections.<Vertex>emptyList().iterator());
    when(vertex.keys()).thenReturn(singleton("name"));
    when(vertex.value("name")).thenReturn("nameMock");
    when(graphMock.addVertex(Mockito.anyString())).thenReturn(vertex);
    return graphMock;
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Graph(org.apache.tinkerpop.gremlin.structure.Graph) Neo4jGraph(org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph) Produces(javax.enterprise.inject.Produces) Database(jakarta.nosql.mapping.Database) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

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

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