GraphElementFactory implements VertexProvider<Node>, EdgeProvider<Node, Edge> { public Edge createEdge(final Node from, final Node to, final String name, final List<String> labels, final Map<String, Object> attributesMap) { return new Edge(from, to, name, labels, toEdgeAttributes(attributesMap)); } GraphElementFactory(final List<Class<?>> entityClasses); @Override Edge buildEdge(final Node from, final Node to, final String name, final Map<String, Attribute> edgeAttributes); Edge createEdge(final Node from, final Node to, final String name, final List<String> labels,
            final Map<String, Object> attributesMap); @Override Node buildVertex(final String name, final Map<String, Attribute> nodeAttributes); Node createNode(final String name, final List<String> labels, final Map<String, Object> attributesMap);  }
@Test public void testCreateEdge() throws NoSuchClassException { final String nodeAId = "a"; final List<String> nodeALabels = Arrays.asList("A"); final Map<String, Object> nodeAAttributes = ImmutableMap.<String, Object>builder().put("id", 1l).put("value", "foo").build(); final String nodeBId = "b"; final List<String> nodeBLabels = Arrays.asList("A"); final Map<String, Object> nodeBAttributes = ImmutableMap.<String, Object>builder().put("id", 2l).put("value", "boo").build(); final String edgeId = "e"; final List<String> edgeLabels = Arrays.asList("edge"); final Map<String, Object> edgeAttributes = ImmutableMap.<String, Object>builder().put("value", "moo").build(); final Node nodeA = factory.createNode(nodeAId, nodeALabels, nodeAAttributes); final Node nodeB = factory.createNode(nodeBId, nodeBLabels, nodeBAttributes); final Edge edge = factory.createEdge(nodeA, nodeB, edgeId, edgeLabels, edgeAttributes); assertThat(edge, notNullValue()); assertThat(edge.getId(), equalTo(edgeId)); assertThat(edge.getLabels(), equalTo(edgeLabels)); assertThat(edge.getAttributes().size(), equalTo(1)); assertThat(edge.getSourceNode(), equalTo(nodeA)); assertThat(edge.getTargetNode(), equalTo(nodeB)); final Attribute idAttribute = edge.getAttributes().get(0); assertThat(idAttribute.getName(), equalTo("value")); assertThat(idAttribute.getValue(), equalTo("moo")); assertThat(idAttribute.isId(), equalTo(Boolean.FALSE)); }