use of org.umlg.sqlg.sql.parse.ReplacedStep in project sqlg by pietermartin.
the class TestHasLabelAndId method testOutWithHasLabelAndHasWithinId.
@Test
public void testOutWithHasLabelAndHasWithinId() {
Vertex a = this.sqlgGraph.addVertex(T.label, "A");
Vertex b = this.sqlgGraph.addVertex(T.label, "B");
Vertex b2 = this.sqlgGraph.addVertex(T.label, "B");
Vertex c = this.sqlgGraph.addVertex(T.label, "C");
Vertex d = this.sqlgGraph.addVertex(T.label, "D");
a.addEdge("ab", b);
a.addEdge("ab", b2);
a.addEdge("ac", c);
a.addEdge("ad", d);
this.sqlgGraph.tx().commit();
DefaultGraphTraversal<Vertex, Vertex> traversal = (DefaultGraphTraversal<Vertex, Vertex>) this.sqlgGraph.traversal().V().hasLabel("A").out().hasLabel("B", "C", "D").has(T.id, P.within(b.id(), c.id()));
List<Vertex> vertices = traversal.toList();
Assert.assertEquals(2, vertices.size());
Assert.assertTrue(vertices.contains(b) && vertices.contains(c));
Assert.assertEquals(1, traversal.getSteps().size());
Assert.assertTrue(traversal.getSteps().get(0) instanceof SqlgGraphStep);
SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) traversal.getSteps().get(0);
Assert.assertEquals(2, sqlgGraphStep.getReplacedSteps().size());
ReplacedStep replacedStep = (ReplacedStep) sqlgGraphStep.getReplacedSteps().get(0);
Assert.assertEquals(1, replacedStep.getLabelHasContainers().size());
replacedStep = (ReplacedStep) sqlgGraphStep.getReplacedSteps().get(1);
Assert.assertEquals(2, replacedStep.getLabelHasContainers().size());
}
use of org.umlg.sqlg.sql.parse.ReplacedStep in project sqlg by pietermartin.
the class TestHasLabelAndId method testConsecutiveEqHasIdAndLabels6.
@Test
public void testConsecutiveEqHasIdAndLabels6() {
Vertex a = this.sqlgGraph.addVertex(T.label, "A");
Vertex b = this.sqlgGraph.addVertex(T.label, "B");
Vertex b2 = this.sqlgGraph.addVertex(T.label, "B");
Vertex c = this.sqlgGraph.addVertex(T.label, "C");
Vertex d = this.sqlgGraph.addVertex(T.label, "D");
this.sqlgGraph.tx().commit();
DefaultGraphTraversal<Vertex, Vertex> traversal = (DefaultGraphTraversal<Vertex, Vertex>) this.sqlgGraph.traversal().V().hasLabel("A", "B", "C").hasId(b.id()).hasId(b.id());
List<Vertex> vertices = traversal.toList();
Assert.assertEquals(1, vertices.size());
Assert.assertEquals(1, traversal.getSteps().size());
Assert.assertTrue(traversal.getSteps().get(0) instanceof SqlgGraphStep);
SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) traversal.getSteps().get(0);
Assert.assertEquals(1, sqlgGraphStep.getReplacedSteps().size());
ReplacedStep replacedStep = (ReplacedStep) sqlgGraphStep.getReplacedSteps().get(0);
Assert.assertEquals(3, replacedStep.getLabelHasContainers().size());
}
use of org.umlg.sqlg.sql.parse.ReplacedStep in project sqlg by pietermartin.
the class TestHasLabelAndId method testConsecutiveEqNeqHasLabels2.
@Test
public void testConsecutiveEqNeqHasLabels2() {
Vertex a = this.sqlgGraph.addVertex(T.label, "A");
Vertex b = this.sqlgGraph.addVertex(T.label, "B");
Vertex c = this.sqlgGraph.addVertex(T.label, "C");
Vertex d = this.sqlgGraph.addVertex(T.label, "D");
this.sqlgGraph.tx().commit();
DefaultGraphTraversal<Vertex, Vertex> traversal = (DefaultGraphTraversal<Vertex, Vertex>) this.sqlgGraph.traversal().V().hasLabel("A").has(T.label, P.neq("B"));
Assert.assertEquals(1, traversal.toList().size());
Assert.assertEquals(1, traversal.getSteps().size());
Assert.assertTrue(traversal.getSteps().get(0) instanceof SqlgGraphStep);
SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) traversal.getSteps().get(0);
Assert.assertEquals(1, sqlgGraphStep.getReplacedSteps().size());
ReplacedStep replacedStep = (ReplacedStep) sqlgGraphStep.getReplacedSteps().get(0);
Assert.assertEquals(2, replacedStep.getLabelHasContainers().size());
}
use of org.umlg.sqlg.sql.parse.ReplacedStep in project sqlg by pietermartin.
the class TestHasLabelAndId method testOutWithHasLabelAndHasId.
@Test
public void testOutWithHasLabelAndHasId() {
Vertex a = this.sqlgGraph.addVertex(T.label, "A");
Vertex b = this.sqlgGraph.addVertex(T.label, "B");
Vertex b2 = this.sqlgGraph.addVertex(T.label, "B");
Vertex c = this.sqlgGraph.addVertex(T.label, "C");
Vertex d = this.sqlgGraph.addVertex(T.label, "D");
a.addEdge("ab", b);
a.addEdge("ab", b2);
a.addEdge("ac", c);
a.addEdge("ad", d);
this.sqlgGraph.tx().commit();
DefaultGraphTraversal<Vertex, Vertex> traversal = (DefaultGraphTraversal<Vertex, Vertex>) this.sqlgGraph.traversal().V().hasLabel("A").out().hasLabel("B").hasId(b.id());
List<Vertex> vertices = traversal.toList();
Assert.assertEquals(1, vertices.size());
Assert.assertEquals(1, traversal.getSteps().size());
Assert.assertTrue(traversal.getSteps().get(0) instanceof SqlgGraphStep);
SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) traversal.getSteps().get(0);
Assert.assertEquals(2, sqlgGraphStep.getReplacedSteps().size());
ReplacedStep replacedStep = (ReplacedStep) sqlgGraphStep.getReplacedSteps().get(0);
Assert.assertEquals(1, replacedStep.getLabelHasContainers().size());
replacedStep = (ReplacedStep) sqlgGraphStep.getReplacedSteps().get(1);
Assert.assertEquals(2, replacedStep.getLabelHasContainers().size());
}
use of org.umlg.sqlg.sql.parse.ReplacedStep in project sqlg by pietermartin.
the class TestHasLabelAndId method testInWithHasLabelAndHasWithinId2.
@Test
public void testInWithHasLabelAndHasWithinId2() {
Vertex a = this.sqlgGraph.addVertex(T.label, "A");
Vertex b = this.sqlgGraph.addVertex(T.label, "B");
Vertex b2 = this.sqlgGraph.addVertex(T.label, "B");
Vertex c = this.sqlgGraph.addVertex(T.label, "C");
Vertex d = this.sqlgGraph.addVertex(T.label, "D");
b.addEdge("ab", a);
b2.addEdge("ab", a);
c.addEdge("ac", a);
d.addEdge("ad", a);
this.sqlgGraph.tx().commit();
DefaultGraphTraversal<Vertex, Vertex> traversal = (DefaultGraphTraversal<Vertex, Vertex>) this.sqlgGraph.traversal().V().hasLabel("A").in().hasLabel("B", "C", "D").has(T.id, P.within(b.id(), c.id()));
List<Vertex> vertices = traversal.toList();
Assert.assertEquals(2, vertices.size());
Assert.assertTrue(vertices.contains(b) && vertices.contains(c));
Assert.assertEquals(1, traversal.getSteps().size());
Assert.assertTrue(traversal.getSteps().get(0) instanceof SqlgGraphStep);
SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) traversal.getSteps().get(0);
Assert.assertEquals(2, sqlgGraphStep.getReplacedSteps().size());
ReplacedStep replacedStep = (ReplacedStep) sqlgGraphStep.getReplacedSteps().get(0);
Assert.assertEquals(1, replacedStep.getLabelHasContainers().size());
replacedStep = (ReplacedStep) sqlgGraphStep.getReplacedSteps().get(1);
Assert.assertEquals(2, replacedStep.getLabelHasContainers().size());
}
Aggregations