use of com.datastax.dse.driver.internal.core.metadata.schema.DefaultDseKeyspaceMetadata in project java-driver by datastax.
the class GraphSchemaRefreshTest method should_detect_top_level_graph_engine_update_in_keyspace.
@Test
public void should_detect_top_level_graph_engine_update_in_keyspace() {
// Change only one top-level option (graph_engine)
DefaultDseKeyspaceMetadata newKs1 = newKeyspace("ks1", "Core");
SchemaRefresh refresh = new SchemaRefresh(ImmutableMap.of(KS_WITH_ENGINE.getName(), KS_WITH_ENGINE, OLD_KS1.getName(), newKs1));
MetadataRefresh.Result result = refresh.compute(oldMetadata, false, context);
assertThat(result.newMetadata.getKeyspaces()).hasSize(2);
assertThat(result.events).containsExactly(KeyspaceChangeEvent.updated(OLD_KS1, newKs1));
}
use of com.datastax.dse.driver.internal.core.metadata.schema.DefaultDseKeyspaceMetadata in project java-driver by datastax.
the class GraphSchemaRefreshTest method should_detect_adding_and_renaming_and_removing_edge_label.
@Test
public void should_detect_adding_and_renaming_and_removing_edge_label() {
DefaultDseTableMetadata newTable = newTable(KS_WITH_ENGINE.getName(), CqlIdentifier.fromInternal("tbl"), null, newEdgeMetadata(CqlIdentifier.fromInternal("created"), CqlIdentifier.fromInternal("person"), CqlIdentifier.fromInternal("software")));
DefaultDseKeyspaceMetadata ks = newKeyspace(KS_WITH_ENGINE.getName(), "Core", ImmutableMap.of(CqlIdentifier.fromInternal("tbl"), newTable));
SchemaRefresh refresh = new SchemaRefresh(ImmutableMap.of(KS_WITH_ENGINE.getName(), ks, OLD_KS1.getName(), OLD_KS1));
MetadataRefresh.Result result = refresh.compute(oldMetadata, false, context);
assertThat(result.newMetadata.getKeyspaces()).hasSize(2);
assertThat(result.events).containsExactly(TableChangeEvent.updated(OLD_TABLE, newTable));
assertThat(result.newMetadata.getKeyspaces().get(KS_WITH_ENGINE.getName())).isNotNull();
assertThat(((DseGraphTableMetadata) result.newMetadata.getKeyspaces().get(KS_WITH_ENGINE.getName()).getTable("tbl").get()).getVertex()).isNotNull();
assertThat(((DseGraphTableMetadata) result.newMetadata.getKeyspaces().get(KS_WITH_ENGINE.getName()).getTable("tbl").get()).getEdge().get().getLabelName().asInternal()).isEqualTo("created");
// now rename the edge label
newTable = newTable(KS_WITH_ENGINE.getName(), CqlIdentifier.fromInternal("tbl"), null, newEdgeMetadata(CqlIdentifier.fromInternal("CHANGED"), CqlIdentifier.fromInternal("person"), CqlIdentifier.fromInternal("software")));
ks = newKeyspace(KS_WITH_ENGINE.getName(), "Core", ImmutableMap.of(CqlIdentifier.fromInternal("tbl"), newTable));
refresh = new SchemaRefresh(ImmutableMap.of(KS_WITH_ENGINE.getName(), ks, OLD_KS1.getName(), OLD_KS1));
result = refresh.compute(oldMetadata, false, context);
assertThat(result.newMetadata.getKeyspaces()).hasSize(2);
assertThat(result.events).containsExactly(TableChangeEvent.updated(OLD_TABLE, newTable));
assertThat(((DseGraphTableMetadata) result.newMetadata.getKeyspaces().get(KS_WITH_ENGINE.getName()).getTable("tbl").get()).getEdge().get().getLabelName().asInternal()).isEqualTo("CHANGED");
// now remove the edge label from the table
DefaultMetadata metadataWithEdgeLabel = result.newMetadata;
DefaultDseTableMetadata tableWithRemovedLabel = newTable(KS_WITH_ENGINE.getName(), CqlIdentifier.fromInternal("tbl"), null, null);
ks = newKeyspace(KS_WITH_ENGINE.getName(), "Core", ImmutableMap.of(CqlIdentifier.fromInternal("tbl"), tableWithRemovedLabel));
refresh = new SchemaRefresh(ImmutableMap.of(KS_WITH_ENGINE.getName(), ks, OLD_KS1.getName(), OLD_KS1));
result = refresh.compute(metadataWithEdgeLabel, false, context);
assertThat(result.newMetadata.getKeyspaces()).hasSize(2);
assertThat(result.events).containsExactly(TableChangeEvent.updated(newTable, tableWithRemovedLabel));
assertThat(((DseGraphTableMetadata) result.newMetadata.getKeyspaces().get(KS_WITH_ENGINE.getName()).getTable("tbl").get()).getEdge().isPresent()).isFalse();
}
Aggregations