TinkerGraph implements Graph { public static TinkerGraph open() { return open(EMPTY_CONFIGURATION); } private  TinkerGraph(final Configuration configuration); static TinkerGraph open(); static TinkerGraph open(final Configuration configuration); @Override Vertex addVertex(final Object... keyValues); @Override C compute(final Class<C> graphComputerClass); @Override GraphComputer compute(); @Override Variables variables(); @Override I io(final Io.Builder<I> builder); @Override String toString(); void clear(); @Override void close(); @Override Transaction tx(); @Override Configuration configuration(); @Override Iterator<Vertex> vertices(final Object... vertexIds); @Override Iterator<Edge> edges(final Object... edgeIds); @Override Features features(); void createIndex(final String key, final Class<E> elementClass); void dropIndex(final String key, final Class<E> elementClass); Set<String> getIndexedKeys(final Class<E> elementClass); static final String GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER; static final String GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER; static final String GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER; static final String GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY; static final String GREMLIN_TINKERGRAPH_GRAPH_LOCATION; static final String GREMLIN_TINKERGRAPH_GRAPH_FORMAT; static final String GREMLIN_TINKERGRAPH_ALLOW_NULL_PROPERTY_VALUES; }
@Test(expected = IllegalStateException.class) public void shouldRequireGraphLocationIfFormatIsSet() { final Configuration conf = new BaseConfiguration(); conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "graphml"); TinkerGraph.open(conf); }
@Test(expected = IllegalStateException.class) public void shouldRequireGraphFormatIfLocationIsSet() { final Configuration conf = new BaseConfiguration(); conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, TestHelper.makeTestDataDirectory(TinkerGraphTest.class)); TinkerGraph.open(conf); }
@Test public void shouldFoldPropertyStepForTokens() { final GraphTraversalSource g = TinkerGraph.open().traversal(); g.addV("person").property(VertexProperty.Cardinality.single, "k", "v"). property(T.id , "id"). property(VertexProperty.Cardinality.list, "l", 1). property("x", "y"). property(VertexProperty.Cardinality.list, "l", 2). property("m", "m", "mm", "mm"). property("y", "z").iterate(); assertThat(g.V("id").hasNext(), is(true)); }
@Test public void shouldReservedKeyVerify() { final Set<String> reserved = new HashSet<>(Arrays.asList("something", "id", "label")); final GraphTraversalSource g = TinkerGraph.open().traversal().withStrategies( ReservedKeysVerificationStrategy.build().reservedKeys(reserved).throwException().create()); g.addV("person").property(T.id, 123).iterate(); try { g.addV("person").property("id", 123).iterate(); fail("Verification exception expected"); } catch (IllegalStateException ve) { assertThat(ve.getMessage(), containsString("that is setting a property key to a reserved word")); } try { g.addV("person").property("something", 123).iterate(); fail("Verification exception expected"); } catch (IllegalStateException ve) { assertThat(ve.getMessage(), containsString("that is setting a property key to a reserved word")); } }