org.umlg.sqlg.test.vertex.TestOtherVertex Maven / Gradle / Ivy
package org.umlg.sqlg.test.vertex;
import org.apache.tinkerpop.gremlin.process.traversal.Path;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.Test;
import org.umlg.sqlg.test.BaseTest;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* Date: 2015/11/19
* Time: 6:34 PM
*/
public class TestOtherVertex extends BaseTest {
@Test
public void testOtherV() {
Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "name", "a1");
Vertex b1 = this.sqlgGraph.addVertex(T.label, "B", "name", "b1");
Edge e1 = a1.addEdge("ab", b1);
this.sqlgGraph.tx().commit();
List paths = this.sqlgGraph.traversal().V(a1).outE().otherV().path().toList();
assertEquals(1, paths.size());
List> pathsToAssert = Arrays.asList(
p -> p.size() == 3 && p.get(0).equals(a1) && p.get(1).equals(e1) && p.get(2).equals(b1)
);
for (Predicate pathPredicate : pathsToAssert) {
Optional path = paths.stream().filter(pathPredicate).findAny();
assertTrue(path.isPresent());
assertTrue(paths.remove(path.get()));
}
assertTrue(paths.isEmpty());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy