* This test helps with data conversions on Grateful Dead. No Assertions...run as needed. Never read from the
* GraphML source as it will always use a String identifier.
*/
@Test
public void shouldWriteGratefulDead() throws IOException {
final Graph g = TinkerGraph.open();
final GraphReader reader = KryoReader.build().create();
try (final InputStream stream = AbstractGremlinTest.class.getResourceAsStream("/com/tinkerpop/gremlin/structure/io/kryo/grateful-dead.gio")) {
reader.readGraph(stream, g);
}
final Graph ng = TinkerGraph.open();
g.V().sideEffect(ov -> {
final Vertex v = ov.get();
if (v.label().equals("song"))
ng.addVertex(T.id, Integer.parseInt(v.id().toString()), T.label, "song", "name", v.value("name"), "performances", v.property("performances").orElse(0), "songType", v.property("songType").orElse(""));
else if (v.label().equals("artist"))
ng.addVertex(T.id, Integer.parseInt(v.id().toString()), T.label, "artist", "name", v.value("name"));
else
throw new RuntimeException("damn");
}).iterate();
g.E().sideEffect(oe -> {
final Edge e = oe.get();
final Vertex v2 = ng.v(Integer.parseInt(e.inV().next().id().toString()));
final Vertex v1 = ng.v(Integer.parseInt(e.outV().next().id().toString()));
if (e.label().equals("followedBy"))
v1.addEdge("followedBy", v2, T.id, Integer.parseInt(e.id().toString()), "weight", e.value("weight"));
else if (e.label().equals("sungBy"))
v1.addEdge("sungBy", v2, T.id, Integer.parseInt(e.id().toString()));