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