Search in sources :

Example 11 with KeyspaceMetadata

use of com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata in project janusgraph by JanusGraph.

the class CQLStoreTest method testNewKeyspaceSession.

@Test
public void testNewKeyspaceSession() {
    Metadata metadata = mock(Metadata.class);
    Optional<KeyspaceMetadata> keyspaceMetadataOptional = Optional.empty();
    when(session.getMetadata()).thenReturn(metadata);
    when(metadata.getKeyspace(TEST_KEYSPACE_NAME)).thenReturn(keyspaceMetadataOptional);
    mockManager.initializeKeyspace();
    verify(session, times(1)).execute(any(Statement.class));
}
Also used : Statement(com.datastax.oss.driver.api.core.cql.Statement) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) TableMetadata(com.datastax.oss.driver.api.core.metadata.schema.TableMetadata) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) KeyColumnValueStoreTest(org.janusgraph.diskstorage.KeyColumnValueStoreTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with KeyspaceMetadata

use of com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata in project janusgraph by JanusGraph.

the class CQLStoreTest method testExistTableOpenDatabase.

@Test
public void testExistTableOpenDatabase() throws BackendException {
    // arrange
    String someTableName = "foo";
    Metadata metadata = mock(Metadata.class);
    KeyspaceMetadata keyspaceMetadata = mock(KeyspaceMetadata.class);
    TableMetadata tableMetadata = mock(TableMetadata.class);
    when(keyspaceMetadata.getTable(someTableName)).thenReturn(Optional.of(tableMetadata));
    when(session.getMetadata()).thenReturn(metadata);
    when(metadata.getKeyspace(mockManager.getKeyspaceName())).thenReturn(Optional.of(keyspaceMetadata));
    // act
    mockManager.openDatabase(someTableName, null);
    // assert
    verify(session, never()).execute(any(Statement.class));
}
Also used : TableMetadata(com.datastax.oss.driver.api.core.metadata.schema.TableMetadata) Statement(com.datastax.oss.driver.api.core.cql.Statement) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) TableMetadata(com.datastax.oss.driver.api.core.metadata.schema.TableMetadata) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) KeyColumnValueStoreTest(org.janusgraph.diskstorage.KeyColumnValueStoreTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 13 with KeyspaceMetadata

use of com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata in project janusgraph by JanusGraph.

the class CQLStoreTest method testExistKeyspaceSession.

@Test
public void testExistKeyspaceSession() {
    Metadata metadata = mock(Metadata.class);
    KeyspaceMetadata keyspaceMetadata = mock(KeyspaceMetadata.class);
    Optional<KeyspaceMetadata> keyspaceMetadataOptional = Optional.of(keyspaceMetadata);
    when(session.getMetadata()).thenReturn(metadata);
    when(metadata.getKeyspace(TEST_KEYSPACE_NAME)).thenReturn(keyspaceMetadataOptional);
    mockManager.initializeKeyspace();
    verify(session, never()).execute(any(Statement.class));
}
Also used : Statement(com.datastax.oss.driver.api.core.cql.Statement) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) TableMetadata(com.datastax.oss.driver.api.core.metadata.schema.TableMetadata) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) KeyColumnValueStoreTest(org.janusgraph.diskstorage.KeyColumnValueStoreTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 14 with KeyspaceMetadata

use of com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata in project zipkin by openzipkin.

the class SchemaTest method ensureKeyspaceMetadata_passesWhenVersion3_11_3AndKeyspaceMetadataIsNotNull.

@Test
public void ensureKeyspaceMetadata_passesWhenVersion3_11_3AndKeyspaceMetadataIsNotNull() {
    CqlSession session = mock(CqlSession.class);
    Metadata metadata = mock(Metadata.class);
    Node node = mock(Node.class);
    KeyspaceMetadata keyspaceMetadata = mock(KeyspaceMetadata.class);
    when(session.getMetadata()).thenReturn(metadata);
    when(metadata.getNodes()).thenReturn(Collections.singletonMap(UUID.fromString("11111111-1111-1111-1111-111111111111"), node));
    when(node.getCassandraVersion()).thenReturn(Version.parse("3.11.3"));
    when(metadata.getKeyspace("zipkin2")).thenReturn(Optional.of(keyspaceMetadata));
    assertThat(Schema.ensureKeyspaceMetadata(session, "zipkin2")).isSameAs(keyspaceMetadata);
}
Also used : Node(com.datastax.oss.driver.api.core.metadata.Node) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) CqlSession(com.datastax.oss.driver.api.core.CqlSession) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Test(org.junit.Test)

Example 15 with KeyspaceMetadata

use of com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata in project zipkin by openzipkin.

the class SchemaTest method ensureKeyspaceMetadata_passesWhenVersion3_11_4AndKeyspaceMetadataIsNotNull.

@Test
public void ensureKeyspaceMetadata_passesWhenVersion3_11_4AndKeyspaceMetadataIsNotNull() {
    CqlSession session = mock(CqlSession.class);
    Metadata metadata = mock(Metadata.class);
    Node node = mock(Node.class);
    KeyspaceMetadata keyspaceMetadata = mock(KeyspaceMetadata.class);
    when(session.getMetadata()).thenReturn(metadata);
    when(metadata.getNodes()).thenReturn(Collections.singletonMap(UUID.fromString("11111111-1111-1111-1111-111111111111"), node));
    when(node.getCassandraVersion()).thenReturn(Version.parse("3.11.4"));
    when(metadata.getKeyspace("zipkin2")).thenReturn(Optional.of(keyspaceMetadata));
    assertThat(Schema.ensureKeyspaceMetadata(session, "zipkin2")).isSameAs(keyspaceMetadata);
}
Also used : Node(com.datastax.oss.driver.api.core.metadata.Node) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) CqlSession(com.datastax.oss.driver.api.core.CqlSession) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Test(org.junit.Test)

Aggregations

KeyspaceMetadata (com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata)16 Test (org.junit.jupiter.api.Test)9 Metadata (com.datastax.oss.driver.api.core.metadata.Metadata)7 TableMetadata (com.datastax.oss.driver.api.core.metadata.schema.TableMetadata)5 Statement (com.datastax.oss.driver.api.core.cql.Statement)4 KeyColumnValueStoreTest (org.janusgraph.diskstorage.KeyColumnValueStoreTest)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 CqlSession (com.datastax.oss.driver.api.core.CqlSession)3 Node (com.datastax.oss.driver.api.core.metadata.Node)3 Test (org.junit.Test)2 UdtValue (com.datastax.oss.driver.api.core.data.UdtValue)1 MutableCodecRegistry (com.datastax.oss.driver.api.core.type.codec.registry.MutableCodecRegistry)1 Resources.resourceToString (zipkin2.storage.cassandra.internal.Resources.resourceToString)1