@Test public void createForEdgeCreatesACreateEdgeLogEntry() { Edge edge = edge().withId("id") .withProperty("rev", 1) .withProperty("modified", changeWithTimestamp(1000L)) .build(); LogEntryFactory instance = new LogEntryFactory(); LogEntry entry = instance.createForEdge(edge); assertThat(entry, is(instanceOf(CreateEdgeLogEntry.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);  }