@Override public Vertex addVertex(Visibility visibility, Authorizations authorizations) { return prepareVertex(visibility).save(authorizations); }
@Test public void testAddMultipleVertices() { List<ElementBuilder<Vertex>> elements = new ArrayList<>(); elements.add(graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "v1", VISIBILITY_A)); elements.add(graph.prepareVertex("v2", VISIBILITY_A) .setProperty("prop1", "v2", VISIBILITY_A)); Iterable<Vertex> vertices = graph.addVertices(elements, AUTHORIZATIONS_A_AND_B); assertVertexIds(vertices, new String[]{"v1", "v2"}); if (graph instanceof GraphBaseWithSearchIndex) { ((GraphBaseWithSearchIndex) graph).getSearchIndex().addElements(graph, vertices, AUTHORIZATIONS_A_AND_B); } }
@Test public void testGraphQueryUpdateVertex() throws NoSuchFieldException, IllegalAccessException { graph.prepareVertex("v1", VISIBILITY_EMPTY) .setProperty("age", 25, VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); Vertex v2 = graph.prepareVertex("v2", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); Vertex v3 = graph.prepareVertex("v3", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.addEdge("v2tov3", v2, v3, "", VISIBILITY_EMPTY, AUTHORIZATIONS_A_AND_B); graph.flush(); .setProperty("name", "Joe", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.prepareVertex("v2", VISIBILITY_EMPTY) .setProperty("name", "Bob", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.prepareVertex("v3", VISIBILITY_EMPTY) .setProperty("name", "Same", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.flush();
.addPropertyValue("key1", "prop1", "value1", VISIBILITY_A) .addPropertyValue("key1", "prop1", "value1", VISIBILITY_B) .addPropertyValue("key2", "prop1", "value1", VISIBILITY_A) .save(AUTHORIZATIONS_A);
@Test public void testAlterVertexWithoutIndexing() { if (isDefaultSearchIndex()) { return; } graph.prepareVertex("v1", VISIBILITY_A) .setIndexHint(IndexHint.DO_NOT_INDEX) .save(AUTHORIZATIONS_A); graph.flush(); Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B); v1.prepareMutation() .setProperty("prop1", "value1", VISIBILITY_A) .setIndexHint(IndexHint.DO_NOT_INDEX) .save(AUTHORIZATIONS_A); graph.flush(); Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A_AND_B) .has("prop1", "value1") .vertices(); assertVertexIds(vertices, new String[]{}); }
@Test public void testGraphQueryUpdateVertex() throws NoSuchFieldException, IllegalAccessException { graph.prepareVertex("v1", VISIBILITY_EMPTY) .setProperty("age", 25, VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); Vertex v2 = graph.prepareVertex("v2", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); Vertex v3 = graph.prepareVertex("v3", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.addEdge("v2tov3", v2, v3, "", VISIBILITY_EMPTY, AUTHORIZATIONS_A_AND_B); graph.flush(); .setProperty("name", "Joe", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.prepareVertex("v2", VISIBILITY_EMPTY) .setProperty("name", "Bob", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.prepareVertex("v3", VISIBILITY_EMPTY) .setProperty("name", "Same", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.flush();
@Test public void testMarkPropertyHidden() { Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A) .addPropertyValue("key1", "prop1", "value1", VISIBILITY_A) .addPropertyValue("key1", "prop1", "value1", VISIBILITY_B) .addPropertyValue("key2", "prop1", "value1", VISIBILITY_A)
@Test public void testAlterVertexWithoutIndexing() { if (isDefaultSearchIndex()) { return; } graph.prepareVertex("v1", VISIBILITY_A) .setIndexHint(IndexHint.DO_NOT_INDEX) .save(AUTHORIZATIONS_A); graph.flush(); Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B); v1.prepareMutation() .setProperty("prop1", "value1", VISIBILITY_A) .setIndexHint(IndexHint.DO_NOT_INDEX) .save(AUTHORIZATIONS_A); graph.flush(); Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A_AND_B) .has("prop1", "value1") .vertices(); assertVertexIds(vertices, new String[]{}); }
@Test public void testAddMultipleVertices() { List<ElementBuilder<Vertex>> elements = new ArrayList<>(); elements.add(graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "v1", VISIBILITY_A)); elements.add(graph.prepareVertex("v2", VISIBILITY_A) .setProperty("prop1", "v2", VISIBILITY_A)); Iterable<Vertex> vertices = graph.addVertices(elements, AUTHORIZATIONS_A_AND_B); assertVertexIds(vertices, new String[]{"v1", "v2"}); if (graph instanceof GraphBaseWithSearchIndex) { ((GraphBaseWithSearchIndex) graph).getSearchIndex().addElements(graph, vertices, AUTHORIZATIONS_A_AND_B); } }
@Override public Vertex addVertex(String vertexId, Visibility visibility, Authorizations authorizations) { return prepareVertex(vertexId, visibility).save(authorizations); }
@Test public void testMultivaluedPropertyOrder() { graph.prepareVertex("v1", VISIBILITY_A) .addPropertyValue("a", "prop", "a", VISIBILITY_A) .addPropertyValue("aa", "prop", "aa", VISIBILITY_A) .addPropertyValue("b", "prop", "b", VISIBILITY_A) .addPropertyValue("0", "prop", "0", VISIBILITY_A) .addPropertyValue("A", "prop", "A", VISIBILITY_A) .addPropertyValue("Z", "prop", "Z", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_A); assertEquals("0", v1.getPropertyValue("prop", 0)); assertEquals("A", v1.getPropertyValue("prop", 1)); assertEquals("Z", v1.getPropertyValue("prop", 2)); assertEquals("a", v1.getPropertyValue("prop", 3)); assertEquals("aa", v1.getPropertyValue("prop", 4)); assertEquals("b", v1.getPropertyValue("prop", 5)); }
.setProperty("name", name, visibility) .setProperty("sex", sex, visibility) .setProperty("count", count, visibility) .save(authorizations); i++;
@Override public Vertex addVertex(String vertexId, Visibility visibility, Authorizations authorizations) { return prepareVertex(vertexId, visibility).save(authorizations); }
@Test public void testMultivaluedPropertyOrder() { graph.prepareVertex("v1", VISIBILITY_A) .addPropertyValue("a", "prop", "a", VISIBILITY_A) .addPropertyValue("aa", "prop", "aa", VISIBILITY_A) .addPropertyValue("b", "prop", "b", VISIBILITY_A) .addPropertyValue("0", "prop", "0", VISIBILITY_A) .addPropertyValue("A", "prop", "A", VISIBILITY_A) .addPropertyValue("Z", "prop", "Z", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_A); assertEquals("0", v1.getPropertyValue("prop", 0)); assertEquals("A", v1.getPropertyValue("prop", 1)); assertEquals("Z", v1.getPropertyValue("prop", 2)); assertEquals("a", v1.getPropertyValue("prop", 3)); assertEquals("aa", v1.getPropertyValue("prop", 4)); assertEquals("b", v1.getPropertyValue("prop", 5)); }
@Test public void testNullPropertyValue() { try { graph.prepareVertex("v1", VISIBILITY_EMPTY) .setProperty("prop1", null, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); throw new SecureGraphException("expected null check"); } catch (NullPointerException ex) { assertTrue(ex.getMessage().contains("prop1")); } }
@Override public Vertex addVertex(String vertexId, Visibility vertexVisibility, Authorizations authorizations) { return prepareVertex(vertexId, vertexVisibility).save(authorizations); }
Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A) .addPropertyValue("propid1a", "prop1", "value1a", VISIBILITY_A) .addPropertyValue("propid1b", "prop1", "value1b", VISIBILITY_A) .addPropertyValue("propid2a", "prop2", "value2a", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B);
@Test public void testNullPropertyValue() { try { graph.prepareVertex("v1", VISIBILITY_EMPTY) .setProperty("prop1", null, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); throw new SecureGraphException("expected null check"); } catch (NullPointerException ex) { assertTrue(ex.getMessage().contains("prop1")); } }
@Override public Vertex addVertex(Visibility visibility, Authorizations authorizations) { return prepareVertex(visibility).save(authorizations); }
@Test public void testRemovePropertyWithMutation() { Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A) .addPropertyValue("propid1a", "prop1", "value1a", VISIBILITY_A) .addPropertyValue("propid1b", "prop1", "value1b", VISIBILITY_A) .addPropertyValue("propid2a", "prop2", "value2a", VISIBILITY_A)