@Test public void getPreviousVersionReturnsThePreviousVersion() { UUID edgeId = UUID.randomUUID(); Graph graph = newGraph().withVertex("v1", v -> v.withTimId("id1")) .withVertex("v2", v -> v.withOutgoingRelation("edge", "v1", e -> e.withRev(1).withTim_id(edgeId)) .withOutgoingRelation("edge", "v1", e -> e.withRev(2).withTim_id(edgeId))) .build(); Edge edge = graph.traversal().E().has("tim_id", edgeId.toString()).has("rev", 2).next(); EdgeRetriever instance = new EdgeRetriever(); Edge previousVersion = instance.getPreviousVersion(edge); assertThat(previousVersion, is(likeEdge().withId(edgeId.toString()).withProperty("rev", 1))); }
public Edge getPreviousVersion(Edge edge) { Integer rev = edge.<Integer>value("rev"); Edge previousVersion = null; for (Iterator<Edge> edges = edge.outVertex().edges(Direction.OUT, edge.label()); edges.hasNext(); ) { Edge next = edges.next(); if (next.<Integer>value("rev") == (rev - 1) && Objects.equals(next.inVertex().id(), edge.inVertex().id())) { previousVersion = next; } } return previousVersion; }
EdgeRetriever { public Edge getPreviousVersion(Edge edge) { Integer rev = edge.<Integer>value("rev"); Edge previousVersion = null; for (Iterator<Edge> edges = edge.outVertex().edges(Direction.OUT, edge.label()); edges.hasNext(); ) { Edge next = edges.next(); if (next.<Integer>value("rev") == (rev - 1) && Objects.equals(next.inVertex().id(), edge.inVertex().id())) { previousVersion = next; } } return previousVersion; } }
EdgeRetriever { public Edge getPreviousVersion(Edge edge) { Integer rev = edge.<Integer>value("rev"); Edge previousVersion = null; for (Iterator<Edge> edges = edge.outVertex().edges(Direction.OUT, edge.label()); edges.hasNext(); ) { Edge next = edges.next(); if (next.<Integer>value("rev") == (rev - 1) && Objects.equals(next.inVertex().id(), edge.inVertex().id())) { previousVersion = next; } } return previousVersion; }  }
EdgeRetriever { public Edge getPreviousVersion(Edge edge) { Integer rev = edge.<Integer>value("rev"); Edge previousVersion = null; for (Iterator<Edge> edges = edge.outVertex().edges(Direction.OUT, edge.label()); edges.hasNext(); ) { Edge next = edges.next(); if (next.<Integer>value("rev") == (rev - 1) && Objects.equals(next.inVertex().id(), edge.inVertex().id())) { previousVersion = next; } } return previousVersion; }  Edge getPreviousVersion(Edge edge); }
EdgeRetriever { public Edge getPreviousVersion(Edge edge) { Integer rev = edge.<Integer>value("rev"); Edge previousVersion = null; for (Iterator<Edge> edges = edge.outVertex().edges(Direction.OUT, edge.label()); edges.hasNext(); ) { Edge next = edges.next(); if (next.<Integer>value("rev") == (rev - 1) && Objects.equals(next.inVertex().id(), edge.inVertex().id())) { previousVersion = next; } } return previousVersion; }  Edge getPreviousVersion(Edge edge); static final Logger LOG; }