@Test public void createForEdgeCreatesAnUpdateEdgeLogEntryWhenTheEdgeHasARevHigherThan1() { UUID edgeId = UUID.randomUUID(); Graph graph = newGraph().withVertex("v1", v -> v.withTimId("id1")) .withVertex("v2", v -> v.withOutgoingRelation("edge", "v1", e -> e.withTim_id(edgeId) .withRev(1) .withModified(changeWithTimestamp(1000L))) .withOutgoingRelation("edge", "v1", e -> e.withTim_id(edgeId) .withRev(2) .withModified(changeWithTimestamp(1000L))) ) .build(); Edge edge = graph.traversal().E().has("tim_id", edgeId.toString()).has("rev", 2).next(); LogEntryFactory instance = new LogEntryFactory(); LogEntry entry = instance.createForEdge(edge); assertThat(entry, is(instanceOf(UpdateEdgeLogEntry.class))); }
public LogEntry createForEdge(Edge edge) throws IllegalArgumentException { Property<Integer> revProp = edge.property("rev"); if (!revProp.isPresent()) { String id = edge.value("tim_id"); throw new IllegalArgumentException( String.format("Edge with id '%s' has no property 'rev'. This edge will be ignored.", id) ); } Integer rev = revProp.value(); if (rev > 1) { Edge prevEdge = edgeRetriever.getPreviousVersion(edge); return new UpdateEdgeLogEntry(edge, prevEdge); } return new CreateEdgeLogEntry(edge); }
LogEntryFactory { public LogEntry createForEdge(Edge edge) throws IllegalArgumentException { Property<Integer> revProp = edge.property("rev"); if (!revProp.isPresent()) { String id = edge.value("tim_id"); throw new IllegalArgumentException( String.format("Edge with id '%s' has no property 'rev'. This edge will be ignored.", id) ); } Integer rev = revProp.value(); if (rev > 1) { Edge prevEdge = edgeRetriever.getPreviousVersion(edge); return new UpdateEdgeLogEntry(edge, prevEdge); } return new CreateEdgeLogEntry(edge); } }
LogEntryFactory { public LogEntry createForEdge(Edge edge) throws IllegalArgumentException { Property<Integer> revProp = edge.property("rev"); if (!revProp.isPresent()) { String id = edge.value("tim_id"); throw new IllegalArgumentException( String.format("Edge with id '%s' has no property 'rev'. This edge will be ignored.", id) ); } Integer rev = revProp.value(); if (rev > 1) { Edge prevEdge = edgeRetriever.getPreviousVersion(edge); return new UpdateEdgeLogEntry(edge, prevEdge); } return new CreateEdgeLogEntry(edge); } LogEntryFactory(); }
LogEntryFactory { public LogEntry createForEdge(Edge edge) throws IllegalArgumentException { Property<Integer> revProp = edge.property("rev"); if (!revProp.isPresent()) { String id = edge.value("tim_id"); throw new IllegalArgumentException( String.format("Edge with id '%s' has no property 'rev'. This edge will be ignored.", id) ); } Integer rev = revProp.value(); if (rev > 1) { Edge prevEdge = edgeRetriever.getPreviousVersion(edge); return new UpdateEdgeLogEntry(edge, prevEdge); } return new CreateEdgeLogEntry(edge); } LogEntryFactory(); LogEntry createForVertex(Vertex vertex); LogEntry createForEdge(Edge edge); }
LogEntryFactory { public LogEntry createForEdge(Edge edge) throws IllegalArgumentException { Property<Integer> revProp = edge.property("rev"); if (!revProp.isPresent()) { String id = edge.value("tim_id"); throw new IllegalArgumentException( String.format("Edge with id '%s' has no property 'rev'. This edge will be ignored.", id) ); } Integer rev = revProp.value(); if (rev > 1) { Edge prevEdge = edgeRetriever.getPreviousVersion(edge); return new UpdateEdgeLogEntry(edge, prevEdge); } return new CreateEdgeLogEntry(edge); } LogEntryFactory(); LogEntry createForVertex(Vertex vertex); LogEntry createForEdge(Edge edge);  }