Search in sources :

Example 1 with DseVertexMetadata

use of com.datastax.dse.driver.api.core.metadata.schema.DseVertexMetadata in project dsbulk by datastax.

the class SchemaSettingsTest method should_error_when_vertex_non_existent_but_lower_case_variant_exists.

@Test
void should_error_when_vertex_non_existent_but_lower_case_variant_exists() {
    DseVertexMetadata vertexMetadata = mock(DseVertexMetadata.class);
    when(table.getVertex()).thenAnswer(x -> Optional.of(vertexMetadata));
    when(vertexMetadata.getLabelName()).thenReturn(CqlIdentifier.fromInternal("v1"));
    Config config = TestConfigUtils.createTestConfig("dsbulk.schema", "graph", "ks", "vertex", "\"V1\"");
    SchemaSettings settings = new SchemaSettings(config, MAP_AND_WRITE);
    assertThatThrownBy(() -> settings.init(session, codecFactory, true, false)).isInstanceOf(IllegalArgumentException.class).hasMessage("Vertex label \"V1\" does not exist, however a vertex label v1 was found. Did you mean to use -v v1?");
}
Also used : DseVertexMetadata(com.datastax.dse.driver.api.core.metadata.schema.DseVertexMetadata) Config(com.typesafe.config.Config) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 2 with DseVertexMetadata

use of com.datastax.dse.driver.api.core.metadata.schema.DseVertexMetadata in project dsbulk by datastax.

the class SchemaSettingsTest method should_error_when_graph_options_provided_but_keyspace_not_core_graph.

@Test
void should_error_when_graph_options_provided_but_keyspace_not_core_graph() {
    DseVertexMetadata vertexMetadata = mock(DseVertexMetadata.class);
    when(table.getVertex()).thenAnswer(x -> Optional.of(vertexMetadata));
    when(vertexMetadata.getLabelName()).thenReturn(CqlIdentifier.fromInternal("v1"));
    when(keyspace.getGraphEngine()).thenReturn(Optional.of("Classic"));
    Config config = TestConfigUtils.createTestConfig("dsbulk.schema", "graph", "ks", "vertex", "v1");
    SchemaSettings settings = new SchemaSettings(config, MAP_AND_WRITE);
    assertThatThrownBy(() -> settings.init(session, codecFactory, false, true)).isInstanceOf(IllegalStateException.class).hasMessage("Graph operations requested but provided graph ks was created with an unsupported graph engine: Classic");
}
Also used : DseVertexMetadata(com.datastax.dse.driver.api.core.metadata.schema.DseVertexMetadata) Config(com.typesafe.config.Config) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 3 with DseVertexMetadata

use of com.datastax.dse.driver.api.core.metadata.schema.DseVertexMetadata in project dsbulk by datastax.

the class SchemaSettingsTest method should_locate_existing_vertex_label.

@Test
void should_locate_existing_vertex_label() {
    DseVertexMetadata vertexMetadata = mock(DseVertexMetadata.class);
    when(table.getVertex()).thenAnswer(v -> Optional.of(vertexMetadata));
    when(vertexMetadata.getLabelName()).thenReturn(CqlIdentifier.fromInternal("v1"));
    when(keyspace.getGraphEngine()).thenReturn(Optional.of("Core"));
    Config config = TestConfigUtils.createTestConfig("dsbulk.schema", "graph", "ks", "vertex", "v1");
    SchemaSettings settings = new SchemaSettings(config, MAP_AND_WRITE);
    settings.init(session, codecFactory, true, false);
    assertThat(getInternalState(settings, "table")).isSameAs(table);
}
Also used : DseVertexMetadata(com.datastax.dse.driver.api.core.metadata.schema.DseVertexMetadata) Config(com.typesafe.config.Config) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 4 with DseVertexMetadata

use of com.datastax.dse.driver.api.core.metadata.schema.DseVertexMetadata in project dsbulk by datastax.

the class SchemaSettingsTest method should_error_when_graph_options_provided_but_cluster_is_not_compatible.

@Test
void should_error_when_graph_options_provided_but_cluster_is_not_compatible() {
    DseVertexMetadata vertexMetadata = mock(DseVertexMetadata.class);
    when(table.getVertex()).thenAnswer(x -> Optional.of(vertexMetadata));
    when(vertexMetadata.getLabelName()).thenReturn(CqlIdentifier.fromInternal("v1"));
    Node node = mock(Node.class);
    when(metadata.getNodes()).thenReturn(ImmutableMap.of(UUID.randomUUID(), node));
    Map<String, Object> extras = ImmutableMap.of(DseNodeProperties.DSE_VERSION, Version.parse("6.0.0"));
    when(node.getExtras()).thenReturn(extras);
    when(node.toString()).thenReturn("host1");
    Config config = TestConfigUtils.createTestConfig("dsbulk.schema", "graph", "ks", "vertex", "v1");
    SchemaSettings settings = new SchemaSettings(config, MAP_AND_WRITE);
    assertThatThrownBy(() -> settings.init(session, codecFactory, false, true)).isInstanceOf(IllegalStateException.class).hasMessage("Graph operations not available due to incompatible cluster");
    assertThat(logs).hasMessageContaining("Incompatible cluster detected. Graph functionality is only compatible with").hasMessageContaining("The following nodes do not appear to be running DSE").hasMessageContaining("host1");
}
Also used : DseVertexMetadata(com.datastax.dse.driver.api.core.metadata.schema.DseVertexMetadata) Config(com.typesafe.config.Config) Node(com.datastax.oss.driver.api.core.metadata.Node) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 5 with DseVertexMetadata

use of com.datastax.dse.driver.api.core.metadata.schema.DseVertexMetadata in project dsbulk by datastax.

the class SchemaSettingsTest method should_error_when_graph_options_provided_but_keyspace_not_graph.

@Test
void should_error_when_graph_options_provided_but_keyspace_not_graph() {
    DseVertexMetadata vertexMetadata = mock(DseVertexMetadata.class);
    when(table.getVertex()).thenAnswer(x -> Optional.of(vertexMetadata));
    when(vertexMetadata.getLabelName()).thenReturn(CqlIdentifier.fromInternal("v1"));
    Config config = TestConfigUtils.createTestConfig("dsbulk.schema", "graph", "ks", "vertex", "v1");
    SchemaSettings settings = new SchemaSettings(config, MAP_AND_WRITE);
    assertThatThrownBy(() -> settings.init(session, codecFactory, false, true)).isInstanceOf(IllegalStateException.class).hasMessage("Graph operations requested but provided keyspace is not a graph: ks");
}
Also used : DseVertexMetadata(com.datastax.dse.driver.api.core.metadata.schema.DseVertexMetadata) Config(com.typesafe.config.Config) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

DseVertexMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseVertexMetadata)6 Config (com.typesafe.config.Config)6 Test (org.junit.jupiter.api.Test)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 DseEdgeMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseEdgeMetadata)1 DseGraphKeyspaceMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseGraphKeyspaceMetadata)1 DseGraphTableMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseGraphTableMetadata)1 DseTableMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseTableMetadata)1 CqlIdentifier (com.datastax.oss.driver.api.core.CqlIdentifier)1 CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 DefaultProtocolVersion (com.datastax.oss.driver.api.core.DefaultProtocolVersion)1 ProtocolVersion (com.datastax.oss.driver.api.core.ProtocolVersion)1 BatchType (com.datastax.oss.driver.api.core.cql.BatchType)1 ColumnDefinitions (com.datastax.oss.driver.api.core.cql.ColumnDefinitions)1 PreparedStatement (com.datastax.oss.driver.api.core.cql.PreparedStatement)1 Statement (com.datastax.oss.driver.api.core.cql.Statement)1 Metadata (com.datastax.oss.driver.api.core.metadata.Metadata)1 Node (com.datastax.oss.driver.api.core.metadata.Node)1 ColumnMetadata (com.datastax.oss.driver.api.core.metadata.schema.ColumnMetadata)1 IndexMetadata (com.datastax.oss.driver.api.core.metadata.schema.IndexMetadata)1