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