package com.tinkerpop.gremlin.algorithm.generator;

import com.tinkerpop.gremlin.AbstractGremlinTest;
import com.tinkerpop.gremlin.structure.Graph;
import com.tinkerpop.gremlin.structure.Vertex;
import org.javatuples.Triplet;

import java.util.List;

/**
 * @author Stephen Mallette (http://stephen.genoprime.com)
 */
public class AbstractGeneratorTest extends AbstractGremlinTest {

    protected boolean same(final Graph g1, final Graph g2) {
        return g1.V().toList().stream()
                .map(v -> Triplet.<Integer, List<Vertex>, List<Vertex>>with(v.getValue("oid"), v.in().toList(), v.out().toList()))
                .allMatch(p -> {
                    final Vertex v = (Vertex) g2.V().has("oid", p.getValue0()).next();
                    final boolean sameInVertices = sameInVertices(v, p.getValue1());
                    final boolean sameOutVertices = sameOutVertices(v, p.getValue2());
                    System.out.println(String.format("Comparison on IN %s OUT %s", sameInVertices, sameOutVertices));
                    return sameInVertices && sameOutVertices;
                });
    }

    private boolean sameInVertices(final Vertex v, final List<Vertex> inVertices) {
        return inVertices.stream()
                .allMatch(inVertex -> v.in().filter(hv -> hv.get().getValue("oid") == inVertex.getValue("oid")).hasNext());
    }

    private boolean sameOutVertices(final Vertex v, final List<Vertex> outVertices) {
        return outVertices.stream()
                .allMatch(outVertex -> v.out().filter(hv -> hv.get().getValue("oid") == outVertex.getValue("oid")).hasNext());
    }
}

@@ -377,16 +377,440 @@
 Test %7B%0A%0A
+    /**%0A     * Asserts that two graphs are the %22same%22 in way of structure.  It assumes that the graphs both have vertices%0A     * with an %22oid%22 property that is an Integer value.  It iterates each vertex in graph 1, using the %22oid%22 to%0A     * lookup vertices in graph 2.  For each one found it checks both IN and OUT vertices to ensure that they%0A     * attach to the same IN/OUT vertices given their %22oid%22 properties.%0A     */%0A
     prot
@@ -1177,38 +1177,14 @@
     
-final boolean sameInVertices =
+return
  sam
@@ -1216,256 +1216,8 @@
 1())
-;%0A                    final boolean sameOutVertices = sameOutVertices(v, p.getValue2());%0A                    System.out.println(String.format(%22Comparison on IN %25s OUT %25s%22, sameInVertices, sameOutVertices));%0A                    return sameInVertices
  && 
@@ -1231,16 +1231,34 @@
 Vertices
+(v, p.getValue2())
 ;%0A      

Add javadoc and cleanup debug code in generator tests.