* @author Joshua Shinavier (http://fortytwo.net)
*/
public class VertexStreamIteratorTest {
@Test
public void testAll() throws Exception {
Graph g = TinkerFactory.createClassic();
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
final KryoWriter writer = KryoWriter.build().create();
writer.writeVertices(os, g.V(), Direction.BOTH);
final AtomicInteger called = new AtomicInteger(0);
final KryoReader reader = KryoReader.build()
.workingDirectory(File.separator + "tmp").create();
VertexStreamIterator vsi = new VertexStreamIterator(new ByteArrayInputStream(os.toByteArray()), reader);
boolean found = false;
while (vsi.hasNext()) {
Vertex v = vsi.next();
//System.out.println("v = " + v);
//System.out.println("\tin edges: " + count(v.in().toList()));
//System.out.println("\tout edges: " + count(v.out().toList()));
String name = v.<String>property("name").value();
//System.out.println("name: " + name);
if (name.equals("ripple")) {
found = true;
assertEquals(1, count(v.in().toList()));
assertEquals(0, count(v.out().toList()));
}
called.incrementAndGet();
}
assertTrue(found);
assertEquals(count(g.V().toList()), called.get());
}
}