com.syncleus.ferma.EdgeFrame Java Examples
The following examples show how to use
com.syncleus.ferma.EdgeFrame.
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: 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 #2
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 #3
Source File: PolymorphicTypeResolver.java From Ferma with Apache License 2.0 | 6 votes |
@Override public <T> Class<? extends T> resolve(final Element element, final Class<T> kind) { final Property<String> nodeClazzProperty = element.<String>property(this.typeResolutionKey); final String nodeClazz; if( nodeClazzProperty.isPresent() ) nodeClazz = nodeClazzProperty.value(); else return kind; final Class<T> nodeKind = (Class<T>) this.reflectionCache.forName(nodeClazz); if (kind.isAssignableFrom(nodeKind) || kind.equals(VertexFrame.class) || kind.equals(EdgeFrame.class) || kind.equals(AbstractVertexFrame.class) || kind.equals(AbstractEdgeFrame.class) || kind. equals(Object.class)) return nodeKind; else return kind; }
Example #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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"); }
Example #13
Source File: IncidenceMethodHandlerTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testGetSonEdgesDefault() { 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 EdgeFrame> childEdgeIterator = father.getSonEdges(); Assert.assertTrue(childEdgeIterator.hasNext()); final EdgeFrame childEdge = childEdgeIterator.next(); Assert.assertEquals(childEdge.getElement().outVertex().property("name").value(), "hercules"); }
Example #14
Source File: UntypedTypeResolverTest.java From Ferma with Apache License 2.0 | 5 votes |
@Test public void testResolveWithDefault() { Element mockElement = Mockito.mock(Element.class); Assert.assertEquals(resolver.resolve(mockElement, VertexFrame.class), TVertex.class); Mockito.verifyZeroInteractions(mockElement); Assert.assertEquals(resolver.resolve(mockElement, AbstractVertexFrame.class), TVertex.class); Mockito.verifyZeroInteractions(mockElement); Assert.assertEquals(resolver.resolve(mockElement, EdgeFrame.class), TEdge.class); Mockito.verifyZeroInteractions(mockElement); Assert.assertEquals(resolver.resolve(mockElement, AbstractEdgeFrame.class), TEdge.class); Mockito.verifyZeroInteractions(mockElement); Assert.assertEquals(resolver.resolve(mockElement, God.class), God.class); Mockito.verifyZeroInteractions(mockElement); }
Example #15
Source File: GraphTypeManager.java From windup with Eclipse Public License 1.0 | 5 votes |
@Override public void init(Element element, Class<?> kind) { if (VertexFrame.class.isAssignableFrom(kind) || EdgeFrame.class.isAssignableFrom(kind)) { addTypeToElement((Class<? extends WindupFrame<?>>) kind, element); } }
Example #16
Source File: UntypedTypeResolver.java From Ferma with Apache License 2.0 | 5 votes |
@Override public <T> Class<? extends T> resolve(final Element element, final Class<T> kind) { if (VertexFrame.class.equals(kind) || AbstractVertexFrame.class.equals(kind)) return (Class<? extends T>) TVertex.class; else if (EdgeFrame.class.equals(kind) || AbstractEdgeFrame.class.equals(kind)) return (Class<? extends T>) TEdge.class; return kind; }
Example #17
Source File: AbstractAnnotationFrameFactory.java From windup with Eclipse Public License 1.0 | 4 votes |
private <E> Class<? extends E> constructClass(final Element element, final Class<E> clazz) { Class constructedClass = constructedClassCache.get(clazz); if (constructedClass != null) return constructedClass; DynamicType.Builder<? extends E> classBuilder; if (clazz.isInterface()) { if (element instanceof Vertex) classBuilder = (DynamicType.Builder<? extends E>) new ByteBuddy().subclass(AbstractVertexFrame.class); else if (element instanceof Edge) classBuilder = (DynamicType.Builder<? extends E>) new ByteBuddy().subclass(AbstractEdgeFrame.class); else throw new IllegalStateException("class is neither an Edge or a vertex!"); if (clazz.getCanonicalName().contains("ByteBuddy")) { // if the input class is itself a bytebuddy class, only take its interfaces classBuilder = classBuilder.implement(clazz.getInterfaces()); } else { classBuilder = classBuilder.implement(clazz); } } else { if (!(element instanceof Vertex || element instanceof Edge)) throw new IllegalStateException("element is neither an edge nor a vertex"); else if (element instanceof Vertex && !VertexFrame.class.isAssignableFrom(clazz)) throw new IllegalStateException(clazz.getName() + " Class is not a type of VertexFrame"); else if (element instanceof Edge && !EdgeFrame.class.isAssignableFrom(clazz)) throw new IllegalStateException(clazz.getName() + " Class is not a type of EdgeFrame"); classBuilder = new ByteBuddy().subclass(clazz); } classBuilder = classBuilder.defineField("reflectionCache", ReflectionCache.class, Visibility.PRIVATE, FieldManifestation.PLAIN) .implement(CachesReflection.class).intercept(FieldAccessor.ofBeanProperty()); /* * Just a hack so that our generified frame types can work. * * This information will not really be used by the generated class. */ classBuilder = classBuilder.typeVariable("T"); // try and construct any abstract methods that are left for (final Method method : clazz.getMethods()) if (isAbstract(method)) annotation_loop: for (final Annotation annotation : method.getAnnotations()) { final MethodHandler handler = methodHandlers.get(annotation.annotationType()); if (handler != null) { classBuilder = handler.processMethod(classBuilder, method, annotation); break; } } DynamicType.Unloaded unloadedClass = classBuilder.make(); constructedClass = unloadedClass.load(this.classLoader, ClassLoadingStrategy.Default.WRAPPER).getLoaded(); this.constructedClassCache.put(clazz, constructedClass); return constructedClass; }
Example #18
Source File: ReframingEdgeIterator.java From Ferma with Apache License 2.0 | 4 votes |
public ReframingEdgeIterator(Iterator<? extends EdgeFrame> edgeFrameIterator, Class<T> framedType) { this.edgeFrameIterator = edgeFrameIterator; this.framedType = framedType; }
Example #19
Source File: IncidenceHandlerWithJavaClassVerticesTest.java From Ferma with Apache License 2.0 | 4 votes |
@Test public void testGetEdgesIteratorDefault() { Iterator<EdgeFrame> actualLinkedListIfaces = linkedList.getImplementedInterfaceEdgeFrames(); Iterator<ImplementsEdge> actialEdgesReframed = new ReframingEdgeIterator<>(actualLinkedListIfaces, ImplementsEdge.class); assertImplementsEdges(linkedList, getLinkedListExpectedImplIfaces(), actialEdgesReframed); }
Example #20
Source File: IncidenceHandlerWithJavaClassVerticesTest.java From Ferma with Apache License 2.0 | 4 votes |
@Test public void testGetEdgesListDefault() { Iterator<EdgeFrame> actualLinkedListIfaces = linkedList.getImplementedInterfaceEdgeFramesList().iterator(); Iterator<ImplementsEdge> actialEdgesReframed = new ReframingEdgeIterator<>(actualLinkedListIfaces, ImplementsEdge.class); assertImplementsEdges(linkedList, getLinkedListExpectedImplIfaces(), actialEdgesReframed); }
Example #21
Source File: IncidenceHandlerWithJavaClassVerticesTest.java From Ferma with Apache License 2.0 | 4 votes |
@Test public void testGetEdgesSetDefault() { Iterator<EdgeFrame> actualLinkedListIfaces = linkedList.getImplementedInterfaceEdgeFramesSet().iterator(); Iterator<ImplementsEdge> actialEdgesReframed = new ReframingEdgeIterator<>(actualLinkedListIfaces, ImplementsEdge.class); assertImplementsEdges(linkedList, getLinkedListExpectedImplIfaces(), actialEdgesReframed); }
Example #22
Source File: IncidenceHandlerWithJavaClassVerticesTest.java From Ferma with Apache License 2.0 | 4 votes |
@Test public void testGetBothDirectionsEdgesDefaultUntyped() { Iterator<EdgeFrame> actualEdges = abstractList.getBothDirectionsExtendEdgeFrames(); Iterator<ExtendsEdge> framedExtendsEdges = new ReframingEdgeIterator<>(actualEdges, ExtendsEdge.class); assertExtendsEdges(getAbstrListBothDirectionsExtEdges(), framedExtendsEdges); }
Example #23
Source File: IncidenceHandlerWithJavaClassVerticesTest.java From Ferma with Apache License 2.0 | 4 votes |
@Test public void testGetBothDirectionsEdgesDefaultUntypedList() { Iterator<EdgeFrame> actualEdges = abstractList.getBothDirectionsExtendEdgeFramesList().iterator(); Iterator<ExtendsEdge> framedExtendsEdges = new ReframingEdgeIterator<>(actualEdges, ExtendsEdge.class); assertExtendsEdges(getAbstrListBothDirectionsExtEdges(), framedExtendsEdges); }
Example #24
Source File: IncidenceHandlerWithJavaClassVerticesTest.java From Ferma with Apache License 2.0 | 4 votes |
@Test public void testGetBothDirectionsEdgesDefaultUntypedSet() { Iterator<EdgeFrame> actualEdges = abstractList.getBothDirectionsExtendEdgeFramesSet().iterator(); Iterator<ExtendsEdge> framedExtendsEdges = new ReframingEdgeIterator<>(actualEdges, ExtendsEdge.class); assertExtendsEdges(getAbstrListBothDirectionsExtEdges(), framedExtendsEdges); }
Example #25
Source File: OutVertexMethodHandler.java From Ferma with Apache License 2.0 | 4 votes |
@RuntimeType public static Object getVertex(@This final EdgeFrame thiz, @Origin final Method method) { return thiz.traverse(GraphTraversal::outV).next(method.getReturnType()); }
Example #26
Source File: ReflectionUtilityTest.java From Ferma with Apache License 2.0 | 4 votes |
public void doesAcceptEdgeFrame(EdgeFrame frame) { // Implementation is irrelevant }
Example #27
Source File: JavaInterfaceVertex.java From Ferma with Apache License 2.0 | 4 votes |
@Incidence(label = "implements", direction = Direction.BOTH, operation = Incidence.Operation.GET) EdgeFrame getAnyImplementsEdge();
Example #28
Source File: JavaClassVertex.java From Ferma with Apache License 2.0 | 4 votes |
@Incidence(label = "extends", direction = Direction.BOTH, operation = Incidence.Operation.GET) Set<EdgeFrame> getBothDirectionsExtendEdgeFramesSet();
Example #29
Source File: JavaClassVertex.java From Ferma with Apache License 2.0 | 4 votes |
@Incidence(label = "extends", direction = Direction.BOTH, operation = Incidence.Operation.GET) List<EdgeFrame> getBothDirectionsExtendEdgeFramesList();
Example #30
Source File: JavaClassVertex.java From Ferma with Apache License 2.0 | 4 votes |
@Incidence(label = "extends", direction = Direction.BOTH, operation = Incidence.Operation.GET) Iterator<EdgeFrame> getBothDirectionsExtendEdgeFrames();