Refine search
/** * Tests that timestamped edges can be updated */ @Test public void testTimestampedEdgeUpdates() { clopen(option(GraphDatabaseConfiguration.STORE_META_TIMESTAMPS, "edgestore"), true, option(GraphDatabaseConfiguration.STORE_META_TTL, "edgestore"), true); // Transaction 1: Init graph with two vertices and one edge TitanTransaction tx = graph.buildTransaction().commitTime(Instant.ofEpochSecond(100)).start(); TitanVertex v1 = tx.addVertex(); TitanVertex v2 = tx.addVertex(); Edge e = v1.addEdge("related",v2); e.property("time", 25); tx.commit(); tx = graph.buildTransaction().commitTime(Instant.ofEpochSecond(200)).start(); v1 = tx.getVertex(v1.longId()); assertNotNull(v1); e = Iterators.getOnlyElement(v1.edges(Direction.OUT, "related")); assertNotNull(e); assertEquals(Integer.valueOf(25), e.value("time")); e.property("time", 125); tx.commit(); tx = graph.buildTransaction().commitTime(Instant.ofEpochSecond(300)).start(); v1 = tx.getVertex(v1.longId()); assertNotNull(v1); e = Iterators.getOnlyElement(v1.edges(Direction.OUT, "related")); assertEquals(Integer.valueOf(125), e.value("time")); e.remove(); tx.commit(); }
/** * Tests that timestamped edges can be updated */ @Test public void testTimestampedEdgeUpdates() { clopen(option(GraphDatabaseConfiguration.STORE_META_TIMESTAMPS, "edgestore"), true, option(GraphDatabaseConfiguration.STORE_META_TTL, "edgestore"), true); // Transaction 1: Init graph with two vertices and one edge JanusGraphTransaction tx = graph.buildTransaction().commitTime(Instant.ofEpochSecond(100)).start(); JanusGraphVertex v1 = tx.addVertex(); JanusGraphVertex v2 = tx.addVertex(); Edge e = v1.addEdge("related",v2); e.property("time", 25); tx.commit(); tx = graph.buildTransaction().commitTime(Instant.ofEpochSecond(200)).start(); v1 = tx.getVertex(v1.longId()); assertNotNull(v1); e = Iterators.getOnlyElement(v1.edges(Direction.OUT, "related")); assertNotNull(e); assertEquals(Integer.valueOf(25), e.value("time")); e.property("time", 125); tx.commit(); tx = graph.buildTransaction().commitTime(Instant.ofEpochSecond(300)).start(); v1 = tx.getVertex(v1.longId()); assertNotNull(v1); e = Iterators.getOnlyElement(v1.edges(Direction.OUT, "related")); assertEquals(Integer.valueOf(125), e.value("time")); e.remove(); tx.commit(); }
@Test public void testIndexing() throws InterruptedException { e.property("text", "Vertex " + words[i % words.length]); e.property("name",words[i % words.length]); e.property("time", i); e.property("category", i % numCategories); e.property("group", i % numGroups); e.property("location", Geoshape.point(0.0 + offset, 0.0 + offset)); if (i % 2 == 0) { e.property("boundary", Geoshape.line(Arrays.asList(new double[][] { {offset-0.1, offset-0.1}, {offset+0.1, offset-0.1}, {offset+0.1, offset+0.1}, {offset-0.1, offset+0.1}}))); } else { e.property("boundary", Geoshape.polygon(Arrays.asList(new double[][] {{offset-0.1,offset-0.1},{offset+0.1,offset-0.1},{offset+0.1,offset+0.1},{offset-0.1,offset+0.1},{offset-0.1,offset-0.1}})));
@Test @SuppressWarnings("deprecation") public void testThreadBoundTx() { assertEquals(5, tmpE.<Integer>value("time") % 10); e3.property("time", 35); assertEquals(35, e3.<Integer>value("time").intValue()); e4.property("type", 2); TitanEdge ef = getOnlyElement(v1.query().direction(Direction.OUT).labels("friend").edges()); assertEquals(ef, (Edge) getOnlyElement(graph.query().has("type", 0).edges())); e3.property("time", 45); assertEquals(45, e3.<Integer>value("time").intValue()); e2.property("time", 25); assertEquals(25, e2.<Integer>value("time").intValue()); v3 = graph.addVertex(); Edge e = v1.addEdge("knows", v3); assertFalse(e.property("age").isPresent());
@Test @SuppressWarnings("deprecation") public void testThreadBoundTx() { assertEquals(5, tmpE.<Integer>value("time") % 10); e3.property("time", 35); assertEquals(35, e3.<Integer>value("time").intValue()); e4.property("type", 2); final JanusGraphEdge ef = Iterables.getOnlyElement(v1.query().direction(Direction.OUT).labels("friend").edges()); assertEquals(ef, getOnlyElement(graph.query().has("type", 0).edges())); e3.property("time", 45); assertEquals(45, e3.<Integer>value("time").intValue()); e2.property("time", 25); assertEquals(25, e2.<Integer>value("time").intValue()); v3 = graph.addVertex(); Edge e = v1.addEdge("knows", v3); assertFalse(e.property("age").isPresent());
@Test public void testEdgeTTLWithMixedIndices() throws Exception { if (!features.hasCellTTL() || !indexFeatures.supportsDocumentTTL()) { e1.property("time", time1); Edge e2 = v2.addEdge("likes", v3, "name", "v2 likes v3", "text", "this won't match anything"); long time2 = time1 + 1; e2.property("time", time2);
@Test public void testVertexPartitioning() throws Exception { Object[] options = {option(GraphDatabaseConfiguration.IDS_FLUSH), false}; vs[vi].property(VertexProperty.Cardinality.single, "sig", t); Edge e = vs[vi].addEdge("knows", g1); e.property("sig", t); e = g1.addEdge("knows", vs[vi]); e.property("sig", t); if (vi % 2 == 0) { e = vs[vi].addEdge("knows", g2); e.property("sig", t);
@Test public void testEdgeTTLWithMixedIndices() throws Exception { if (!features.hasCellTTL() || !indexFeatures.supportsDocumentTTL()) { e1.property("time", time1); Edge e2 = v2.addEdge("likes", v3, "name", "v2 likes v3", "text", "this won't match anything"); final long time2 = time1 + 1; e2.property("time", time2);
@Test public void testUpdateEdgePropertyOfRemovingEdge() { Edge edge = initEdgeTransfer(); edge.remove(); Assert.assertThrows(IllegalArgumentException.class, () -> { edge.property("message").remove(); }); Assert.assertThrows(IllegalArgumentException.class, () -> { edge.property("message", "*"); }); }
@Test public void testVertexPartitioning() { Object[] options = {option(GraphDatabaseConfiguration.IDS_FLUSH), false}; vs[vi].property(VertexProperty.Cardinality.single, "sig", t); Edge e = vs[vi].addEdge("knows", g1); e.property("sig", t); e = g1.addEdge("knows", vs[vi]); e.property("sig", t); if (vi % 2 == 0) { e = vs[vi].addEdge("knows", g2); e.property("sig", t);
@Test public void testUpdateEdgePropertyTwice() { HugeGraph graph = graph(); Edge edge = initEdgeTransfer(); Assert.assertEquals(500.00F, edge.property("amount").value()); edge.property("amount", 100.00F); edge.property("amount", 200.00F); graph.tx().commit(); List<Edge> edges = graph.traversal().E().toList(); Assert.assertEquals(1, edges.size()); edge = edges.get(0); Assert.assertEquals(200.00F, edge.property("amount").value()); }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) public void shouldHaveStandardStringRepresentationForEdgeProperty() { final Vertex v = graph.addVertex(); final Edge e = v.addEdge("self", v, "short", "s"); final Property p = e.property("short"); assertEquals(StringFactory.propertyString(p), p.toString()); }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) public void shouldHaveTruncatedStringRepresentationForEdgeProperty() { final Vertex v = graph.addVertex(); final Edge e = v.addEdge("self", v, "long", "s"); final Property p = e.property("long", "this is a really long property to truncate"); assertEquals(StringFactory.propertyString(p), p.toString()); }