com.syncleus.ferma.VertexFrame Java Examples
The following examples show how to use
com.syncleus.ferma.VertexFrame.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PropertyMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testObtainName() { final Graph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); Assert.assertEquals("jupiter", father.obtainName()); }
Example #2
Source File: WindupAdjacencyMethodHandler.java From windup with Eclipse Public License 1.0 | 6 votes |
@RuntimeType public static Set getVertexes(@This final VertexFrame thiz, @Origin final Method method) { assert thiz instanceof CachesReflection; final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class); final Direction direction = annotation.direction(); final String label = annotation.label(); return thiz.traverse(input -> { switch (direction) { case IN: return input.in(label); case OUT: return input.out(label); case BOTH: return input.both(label); default: throw new IllegalStateException("Direction not recognized."); } }).toSet(VertexFrame.class); }
Example #3
Source File: VertexFromFramedIterable.java From windup with Eclipse Public License 1.0 | 6 votes |
@Override public Iterator<Vertex> iterator() { return new Iterator<Vertex>() { private final Iterator<? extends VertexFrame> iterator = iterable.iterator(); public void remove() { throw new UnsupportedOperationException(); } public boolean hasNext() { return this.iterator.hasNext(); } public Vertex next() { return iterator.next().getElement(); } }; }
Example #4
Source File: PropertyMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testDeleteName() { final Graph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); father.deleteName(); Assert.assertNull(fatherVertex.getProperty("name")); }
Example #5
Source File: PropertyMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testRemoveName() { final Graph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); father.removeName(); Assert.assertNull(fatherVertex.getProperty("name")); }
Example #6
Source File: WindupAdjacencyMethodHandler.java From windup with Eclipse Public License 1.0 | 6 votes |
@RuntimeType public static Iterator getVertexes(@This final VertexFrame thiz, @Origin final Method method) { assert thiz instanceof CachesReflection; final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class); final Direction direction = annotation.direction(); final String label = annotation.label(); return thiz.traverse(input -> { switch(direction) { case IN: return input.in(label); case OUT: return input.out(label); case BOTH: return input.both(label); default: throw new IllegalStateException("Direction not recognized."); } }).frame(VertexFrame.class); }
Example #7
Source File: WindupAdjacencyMethodHandler.java From windup with Eclipse Public License 1.0 | 6 votes |
@RuntimeType public static Set getVertexes(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) { assert thiz instanceof CachesReflection; final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class); final Direction direction = annotation.direction(); final String label = annotation.label(); final TypeResolver resolver = thiz.getGraph().getTypeResolver(); return thiz.traverse(input -> { switch(direction) { case IN: return resolver.hasType(input.in(label), type); case OUT: return resolver.hasType(input.out(label), type); case BOTH: return resolver.hasType(input.both(label), type); default: throw new IllegalStateException("Direction not recognized."); } }).toSet(type); }
Example #8
Source File: WindupAdjacencyMethodHandler.java From windup with Eclipse Public License 1.0 | 6 votes |
@RuntimeType public static Object getVertexes(@This final VertexFrame thiz, @Origin final Method method) { assert thiz instanceof CachesReflection; final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class); final Direction direction = annotation.direction(); final String label = annotation.label(); try { return thiz.traverse(input -> { switch (direction) { case IN: return input.in(label); case OUT: return input.out(label); case BOTH: return input.both(label); default: throw new IllegalStateException("Direction not recognized."); } }).next(VertexFrame.class); } catch (NoSuchElementException e) { return null; } }
Example #9
Source File: WindupAdjacencyMethodHandler.java From windup with Eclipse Public License 1.0 | 6 votes |
@RuntimeType public static Object getVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) { assert thiz instanceof CachesReflection; final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class); final Direction direction = annotation.direction(); final String label = annotation.label(); final TypeResolver resolver = thiz.getGraph().getTypeResolver(); return thiz.traverse(input -> { switch(direction) { case IN: return resolver.hasType(input.in(label), type); case OUT: return resolver.hasType(input.out(label), type); case BOTH: return resolver.hasType(input.both(label), type); default: throw new IllegalStateException("Direction not recognized."); } }).next(type); }
Example #10
Source File: WindupAdjacencyMethodHandler.java From windup with Eclipse Public License 1.0 | 6 votes |
@RuntimeType public static Object addVertex(@This final VertexFrame thiz, @Origin final Method method) { final VertexFrame newVertex = thiz.getGraph().addFramedVertex(); assert thiz instanceof CachesReflection; final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class); final Direction direction = annotation.direction(); final String label = annotation.label(); switch (direction) { case BOTH: thiz.getGraph().addFramedEdge(newVertex, thiz, label); thiz.getGraph().addFramedEdge(thiz, newVertex, label); break; case IN: thiz.getGraph().addFramedEdge(newVertex, thiz, label); break; case OUT: thiz.getGraph().addFramedEdge(thiz, newVertex, label); break; default: throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT."); } return newVertex; }
Example #11
Source File: WindupAdjacencyMethodHandler.java From windup with Eclipse Public License 1.0 | 6 votes |
@RuntimeType public static Object addVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final VertexFrame newVertex) { assert thiz instanceof CachesReflection; final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class); final Direction direction = annotation.direction(); final String label = annotation.label(); switch (direction) { case BOTH: thiz.getGraph().addFramedEdge(newVertex, thiz, label); thiz.getGraph().addFramedEdge(thiz, newVertex, label); break; case IN: thiz.getGraph().addFramedEdge(newVertex, thiz, label); break; case OUT: thiz.getGraph().addFramedEdge(thiz, newVertex, label); break; default: throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT."); } return newVertex; }
Example #12
Source File: WindupAdjacencyMethodHandler.java From windup with Eclipse Public License 1.0 | 6 votes |
@RuntimeType public static Object addVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final VertexFrame newVertex, @RuntimeType @Argument(1) final ClassInitializer edgeType) { assert thiz instanceof CachesReflection; final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class); final Direction direction = annotation.direction(); final String label = annotation.label(); switch (direction) { case BOTH: thiz.getGraph().addFramedEdge(newVertex, thiz, label, edgeType); thiz.getGraph().addFramedEdge(thiz, newVertex, label, edgeType); break; case IN: thiz.getGraph().addFramedEdge(newVertex, thiz, label, edgeType); break; case OUT: thiz.getGraph().addFramedEdge(thiz, newVertex, label, edgeType); break; default: throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT."); } return newVertex; }
Example #13
Source File: MapInAdjacentVerticesHandler.java From windup with Eclipse Public License 1.0 | 6 votes |
@RuntimeType public static Object execute(@This final ElementFrame thisFrame, @Origin final Method method, @RuntimeType @AllArguments final Object[] args) { final MapInAdjacentVertices ann = ((CachesReflection) thisFrame).getReflectionCache().getAnnotation(method, MapInAdjacentVertices.class); Element thisElement = thisFrame.getElement(); if (!(thisElement instanceof Vertex)) throw new WindupException("Element is not of supported type, must be Vertex, but was: " + thisElement.getClass().getCanonicalName()); Vertex vertex = (Vertex) thisElement; String methodName = method.getName(); if (methodName.startsWith("get")) { return handleGetter(vertex, method, args, ann, thisFrame.getGraph()); } else if (methodName.startsWith("set")) { handleSetter((VertexFrame)thisFrame, method, args, ann, thisFrame.getGraph()); return null; } throw new WindupException("Only get* and set* method names are supported."); }
Example #14
Source File: WindupAdjacencyMethodHandler.java From windup with Eclipse Public License 1.0 | 6 votes |
@RuntimeType public static List getVertexes(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) { assert thiz instanceof CachesReflection; final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class); final Direction direction = annotation.direction(); final String label = annotation.label(); final TypeResolver resolver = thiz.getGraph().getTypeResolver(); return thiz.traverse(input -> { switch(direction) { case IN: return resolver.hasType(input.in(label), type); case OUT: return resolver.hasType(input.out(label), type); case BOTH: return resolver.hasType(input.both(label), type); default: throw new IllegalStateException("Direction not recognized."); } }).toList(type); }
Example #15
Source File: PropertyMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testSetName() { final Graph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); God father = gods.iterator().next(); Assert.assertTrue(father != null); VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); father.setName("joopiter"); gods = framedGraph.traverse( input -> input.V().has("name", "joopiter")).toList(God.class); father = gods.iterator().next(); Assert.assertTrue(father != null); fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "joopiter"); }
Example #16
Source File: PropertyMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testApplyName() { final Graph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); God father = gods.iterator().next(); Assert.assertTrue(father != null); VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); father.applyName("joopiter"); gods = framedGraph.traverse( input -> input.V().has("name", "joopiter")).toList(God.class); father = gods.iterator().next(); Assert.assertTrue(father != null); fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "joopiter"); }
Example #17
Source File: PropertyMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testGetName() { final Graph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); Assert.assertEquals("jupiter", father.getName()); }
Example #18
Source File: InVertexMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testGetSonEdges() { final TinkerGraph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); God father = gods.iterator().next(); Assert.assertTrue(father != null); VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); final Iterator<? extends FatherEdge> childEdgeIterator = father.getSonEdges(FatherEdge.class); Assert.assertTrue(childEdgeIterator.hasNext()); final FatherEdge childEdge = childEdgeIterator.next(); father = childEdge.getFather(); Assert.assertTrue(father != null); fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); }
Example #19
Source File: OutVertexMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testGetSonEdges() { final TinkerGraph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); final Iterator<? extends FatherEdge> childEdgeIterator = father.getSonEdges(FatherEdge.class); Assert.assertTrue(childEdgeIterator.hasNext()); final FatherEdge childEdge = childEdgeIterator.next(); final God son = childEdge.getSon(); Assert.assertTrue(son != null); final VertexFrame sonVertex = son; Assert.assertEquals(sonVertex.getProperty("name"), "hercules"); }
Example #20
Source File: IncidenceMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testDeleteSonEdge() { final TinkerGraph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); final FatherEdge child = father.getSonEdge(FatherEdge.class); Assert.assertNotNull(child); Assert.assertTrue(child instanceof EdgeFrame); final EdgeFrame childEdge = child; Assert.assertEquals(childEdge.getRawTraversal().outV().next().property("name").value(), "hercules"); father.deleteSonEdge(child); Assert.assertFalse(father.getSonEdges(FatherEdge.class).hasNext()); }
Example #21
Source File: IncidenceMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testRemoveSonEdge() { final TinkerGraph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); final FatherEdge child = father.getSonEdge(FatherEdge.class); Assert.assertNotNull(child); Assert.assertTrue(child instanceof EdgeFrame); final EdgeFrame childEdge = child; Assert.assertEquals(childEdge.getRawTraversal().outV().next().property("name").value(), "hercules"); father.removeSonEdge(child); Assert.assertFalse(father.getSonEdges(FatherEdge.class).hasNext()); }
Example #22
Source File: IncidenceMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testGetSonEdgeByType() { final TinkerGraph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); final FatherEdge childEdge = father.getSonEdge(FatherEdge.class); Assert.assertTrue(childEdge != null); final EdgeFrame edge = childEdge; Assert.assertEquals(childEdge.getElement().outVertex().property("name").value(), "hercules"); }
Example #23
Source File: IncidenceMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testGetSonEdgeDefault() { final TinkerGraph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); final EdgeFrame childEdge = father.getSonEdge(); Assert.assertEquals(childEdge.getElement().outVertex().property("name").value(), "hercules"); }
Example #24
Source File: IncidenceMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testGetSonEdgesExtended() { final TinkerGraph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); final Iterator<? extends FatherEdge> childEdgeIterator = father.getSonEdges(FatherEdgeExtended.class); Assert.assertTrue(childEdgeIterator.hasNext()); final FatherEdge childEdge = childEdgeIterator.next(); Assert.assertTrue(childEdge instanceof FatherEdgeExtended); Assert.assertTrue(childEdge instanceof EdgeFrame); final EdgeFrame edge = childEdge; Assert.assertEquals(edge.getElement().outVertex().property("name").value(), "hercules"); }
Example #25
Source File: IncidenceMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testObtainSonEdgesByType() { final TinkerGraph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); final Iterator<? extends FatherEdge> childEdgeIterator = father.obtainSonEdges(FatherEdge.class); Assert.assertTrue(childEdgeIterator.hasNext()); final FatherEdge childEdge = childEdgeIterator.next(); Assert.assertTrue(childEdge != null); final EdgeFrame edge = childEdge; Assert.assertEquals(edge.getElement().outVertex().property("name").value(), "hercules"); }
Example #26
Source File: IncidenceMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testGetSonEdgesSetByType() { final TinkerGraph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); final Set<? extends FatherEdge> childEdges = father.getSonEdgesSet(FatherEdge.class); Assert.assertFalse(childEdges.isEmpty()); final FatherEdge childEdge = childEdges.iterator().next(); Assert.assertTrue(childEdge != null); final EdgeFrame edge = childEdge; Assert.assertEquals(edge.getElement().outVertex().property("name").value(), "hercules"); }
Example #27
Source File: IncidenceMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testGetSonEdgesListByType() { final TinkerGraph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); final List<? extends FatherEdge> childEdges = father.getSonEdgesList(FatherEdge.class); Assert.assertFalse(childEdges.isEmpty()); final FatherEdge childEdge = childEdges.get(0); Assert.assertTrue(childEdge != null); final EdgeFrame edge = childEdge; Assert.assertEquals(edge.getElement().outVertex().property("name").value(), "hercules"); }
Example #28
Source File: IncidenceMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testGetSonEdgesByType() { final TinkerGraph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); final Iterator<? extends FatherEdge> childEdgeIterator = father.getSonEdges(FatherEdge.class); Assert.assertTrue(childEdgeIterator.hasNext()); final FatherEdge childEdge = childEdgeIterator.next(); Assert.assertTrue(childEdge != null); final EdgeFrame edge = childEdge; Assert.assertEquals(edge.getElement().outVertex().property("name").value(), "hercules"); }
Example #29
Source File: IncidenceMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testGetSonEdgesSetDefault() { final TinkerGraph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); final Set<? extends EdgeFrame> sonEdgesSet = father.getSonEdgesSet(); Assert.assertFalse(sonEdgesSet.isEmpty()); final EdgeFrame childEdge = sonEdgesSet.iterator().next(); Assert.assertEquals(childEdge.getElement().outVertex().property("name").value(), "hercules"); }
Example #30
Source File: IncidenceMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testGetSonEdgesListDefault() { final TinkerGraph godGraph = TinkerGraph.open(); GodGraphLoader.load(godGraph); final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES); final List<? extends God> gods = framedGraph.traverse( input -> input.V().has("name", "jupiter")).toList(God.class); final God father = gods.iterator().next(); Assert.assertTrue(father != null); final VertexFrame fatherVertex = father; Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter"); final List<? extends EdgeFrame> edgesList = father.getSonEdgesList(); Assert.assertFalse(edgesList.isEmpty()); final EdgeFrame childEdge = edgesList.get(0); Assert.assertEquals(childEdge.getElement().outVertex().property("name").value(), "hercules"); }