use of nl.knaw.huygens.timbuctoo.server.GraphWrapper in project timbuctoo by HuygensING.
the class DatabaseFixerTest method fixAddsMissingVertices.
@Test
public void fixAddsMissingVertices() {
String vertex1CreatedProp = changeStringWithTimestamp(1500L);
String vertex2CreatedProp = changeStringWithTimestamp(1400L);
GraphWrapper graphWrapper = newGraph().withVertex("v1", v -> v.withTimId("id1").withProperty("rev", 2).withProperty("modified", changeStringWithTimestamp(10000L)).withProperty("created", vertex1CreatedProp).withProperty("isLatest", true)).withVertex("v2", v -> v.withTimId("id2").withProperty("rev", 3).withProperty("modified", changeStringWithTimestamp(10000L)).withProperty("created", vertex2CreatedProp).withProperty("isLatest", true)).wrap();
DatabaseFixer instance = new DatabaseFixer(graphWrapper);
instance.fix();
assertThat(graphWrapper.getGraph().traversal().V().has("tim_id", "id1").toList(), containsInAnyOrder(likeVertex().withTimId("id1").withProperty("rev", 1).withProperty("modified", vertex1CreatedProp), likeVertex().withTimId("id1").withProperty("rev", 2)));
assertThat(graphWrapper.getGraph().traversal().V().has("tim_id", "id2").toList(), containsInAnyOrder(likeVertex().withTimId("id2").withProperty("rev", 1).withProperty("modified", vertex2CreatedProp), likeVertex().withTimId("id2").withProperty("rev", 2).withProperty("modified", vertex2CreatedProp), likeVertex().withTimId("id2").withProperty("rev", 3)));
}
use of nl.knaw.huygens.timbuctoo.server.GraphWrapper in project timbuctoo by HuygensING.
the class DatabaseFixerTest method fixAddsMissingEdges.
@Test
public void fixAddsMissingEdges() {
UUID rel1Id = UUID.fromString("ff65089c-2ded-4af0-95e7-0476979f96b8");
UUID rel2Id = UUID.fromString("a628b090-ec7f-4608-9356-61728355ad5a");
GraphWrapper wrapper = newGraph().withVertex("v1", v -> v.withTimId("id1")).withVertex("v2", v -> v.withTimId("id2").withOutgoingRelation("relatedTo", "v1", r -> r.withTim_id(rel1Id).withRev(2).withIsLatest(true).withModified(changeWithTimestamp(10000L)).withCreated(changeWithTimestamp(1500L)))).withVertex("v3", v -> v.withTimId("id3").withOutgoingRelation("relatedTo", "v2", r -> r.withTim_id(rel2Id).withRev(4).withIsLatest(true).withModified(changeWithTimestamp(10000L)).withCreated(changeWithTimestamp(1000L)))).wrap();
DatabaseFixer databaseFixer = new DatabaseFixer(wrapper);
databaseFixer.fix();
assertThat(wrapper.getGraph().traversal().E().has("tim_id", rel1Id.toString()).toList(), containsInAnyOrder(likeEdge().withId(rel1Id.toString()).withProperty("rev", 1).withModifiedTimestamp(1500L), likeEdge().withId(rel1Id.toString()).withProperty("rev", 2).withModifiedTimestamp(10000L)));
assertThat(wrapper.getGraph().traversal().E().has("tim_id", rel2Id.toString()).toList(), containsInAnyOrder(likeEdge().withId(rel2Id.toString()).withProperty("rev", 1).withModifiedTimestamp(1000L), likeEdge().withId(rel2Id.toString()).withProperty("rev", 2).withModifiedTimestamp(1000L), likeEdge().withId(rel2Id.toString()).withProperty("rev", 3).withModifiedTimestamp(1000L), likeEdge().withId(rel2Id.toString()).withProperty("rev", 4).withModifiedTimestamp(10000L)));
}
use of nl.knaw.huygens.timbuctoo.server.GraphWrapper in project timbuctoo by HuygensING.
the class DatabaseFixerTest method fixAddsAVersionOfRelation.
@Test
public void fixAddsAVersionOfRelation() {
String vertex1CreatedProp = changeStringWithTimestamp(1500L);
GraphWrapper graphWrapper = newGraph().withVertex("v1", v -> v.withTimId("id1").withProperty("rev", 2).withProperty("modified", changeStringWithTimestamp(10000L)).withProperty("created", vertex1CreatedProp).withProperty("isLatest", true)).wrap();
DatabaseFixer instance = new DatabaseFixer(graphWrapper);
instance.fix();
Optional<Vertex> vertex = graphWrapper.getGraph().traversal().V().has("tim_id", "id1").has("rev", 1).tryNext();
assertThat(vertex, is(present()));
Iterator<Edge> versionOfRelations = vertex.get().edges(Direction.OUT, "VERSION_OF");
assertThat(versionOfRelations.hasNext(), is(true));
}
use of nl.knaw.huygens.timbuctoo.server.GraphWrapper in project timbuctoo by HuygensING.
the class DatabaseLogTest method generateAppendsEachVersionOfAnEdgeOnlyOnce.
@Test
public void generateAppendsEachVersionOfAnEdgeOnlyOnce() {
UUID relId = UUID.fromString("ff65089c-2ded-4af0-95e7-0476979f96b8");
GraphWrapper graphWrapper = newGraph().withVertex("v1", v -> v.withTimId("id1").withProperty("modified", getChangeStringWithTimestamp(1464346423L)).withProperty("rev", 3)).withVertex("v2", v -> v.withTimId("id2").withProperty("modified", getChangeStringWithTimestamp(1464346425L)).withProperty("rev", 3).withOutgoingRelation("relatedTo", "v1", r -> r.withTim_id(relId).withRev(1).withModified(changeWithTimestamp(1464346426L))).withOutgoingRelation("relatedTo", "v1", r -> r.withTim_id(relId).withRev(2).withModified(changeWithTimestamp(1464346428L))).withOutgoingRelation("relatedTo", "v1", r -> r.withTim_id(relId).withRev(2).withModified(changeWithTimestamp(1464346428L)))).wrap();
DatabaseLog instance = createInstance(graphWrapper);
instance.generate();
verify(logEntryFactory).createForEdge(argThat(likeEdge().withId(relId.toString()).withProperty("rev", 1)));
verify(logEntryFactory, times(1)).createForEdge(argThat(likeEdge().withId(relId.toString()).withProperty("rev", 2)));
}
use of nl.knaw.huygens.timbuctoo.server.GraphWrapper in project timbuctoo by HuygensING.
the class DatabaseLogTest method generateAppendsAVertexEntryForEachVertexToTheLog.
@Test
public void generateAppendsAVertexEntryForEachVertexToTheLog() throws Exception {
GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withTimId("id1").withProperty("modified", getChangeStringWithTimestamp(1464346423L)).withProperty("rev", 1)).withVertex(v -> v.withTimId("id2").withProperty("modified", getChangeStringWithTimestamp(1464346425L)).withProperty("rev", 1)).withVertex(v -> v.withTimId("id3").withProperty("modified", getChangeStringWithTimestamp(1464346424L)).withProperty("rev", 1)).wrap();
DatabaseLog instance = createInstance(graphWrapper);
instance.generate();
verify(vertexLogEntry, times(3)).appendToLog(any(LogOutput.class));
}
Aggregations