GraphElementFactory implements VertexProvider<Node>, EdgeProvider<Node, Edge> { public Node createNode(final String name, final List<String> labels, final Map<String, Object> attributesMap) throws NoSuchClassException { return new Node(name, labels, toNodeAttributes(labels, 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 testCreateNode() throws NoSuchClassException { final String nodeId = "a"; final List<String> nodeLabels = Arrays.asList("A"); final Map<String, Object> nodeAttributes = ImmutableMap.<String, Object>builder().put("id", 1l).put("value", "foo").build(); final Node node = factory.createNode(nodeId, nodeLabels, nodeAttributes); assertThat(node, notNullValue()); assertThat(node.getId(), equalTo(nodeId)); assertThat(node.getLabels(), equalTo(nodeLabels)); assertThat(node.getAttributes().size(), equalTo(2)); final Attribute idAttribute = node.getAttributes().get(0); assertThat(idAttribute.getName(), equalTo("id")); assertThat(idAttribute.getValue(), equalTo(1l)); assertThat(idAttribute.isId(), equalTo(Boolean.TRUE)); final Attribute valueAttribute = node.getAttributes().get(1); assertThat(valueAttribute.getName(), equalTo("value")); assertThat(valueAttribute.getValue(), equalTo("foo")); assertThat(valueAttribute.isId(), equalTo(Boolean.FALSE)); }