use of nl.knaw.huygens.timbuctoo.databaselog.entry.LogEntryFactory in project timbuctoo by HuygensING.
the class DatabaseLogIntegrationTest method generateFirstAddsTheVerticesAndThenAddsTheEdgesForATimeStamp.
@Test
public void generateFirstAddsTheVerticesAndThenAddsTheEdgesForATimeStamp() {
LogOutput logOutput = mock(LogOutput.class);
UUID rel1Uuid = UUID.fromString("ff65089c-2ded-4af0-95e7-0476979f96b8");
UUID rel2Uuid = UUID.fromString("a628b090-ec7f-4608-9356-61728355ad5a");
GraphWrapper graphWrapper = newGraph().withVertex("v1", v -> v.withTimId("id1").withProperty("modified", changeStringWithTimestamp(1000L)).withProperty("rev", 1)).withVertex("v2", v -> v.withTimId("id2").withProperty("modified", changeStringWithTimestamp(1001L)).withProperty("rev", 1).withOutgoingRelation("isRelatedTo", "v2", r -> r.withTim_id(rel1Uuid).withModified(changeWithTimestamp(1002L)).withRev(1))).withVertex("v3", v -> v.withTimId("id3").withProperty("modified", changeStringWithTimestamp(1002L)).withProperty("rev", 1)).withVertex("v4", v -> v.withTimId("id3").withProperty("modified", changeStringWithTimestamp(4000L)).withProperty("rev", 2).withIncomingRelation("isRelatedTo", "v1", r -> r.withTim_id(rel2Uuid).withModified(changeWithTimestamp(3000L)).withRev(1)).withIncomingRelation("VERSION_OF", "v3")).wrap();
DatabaseLog logGenerator = new DatabaseLog(graphWrapper, new LogEntryFactory(), logOutput);
logGenerator.generate();
InOrder inOrder = inOrder(logOutput);
inOrder.verify(logOutput).newVertex(argThat(likeVertex().withTimId("id1")));
inOrder.verify(logOutput).newVertex(argThat(likeVertex().withTimId("id2")));
inOrder.verify(logOutput).newVertex(argThat(likeVertex().withTimId("id3")));
inOrder.verify(logOutput).newEdge(argThat(likeEdge().withId(rel1Uuid.toString())));
inOrder.verify(logOutput).newEdge(argThat(likeEdge().withId(rel2Uuid.toString())));
inOrder.verify(logOutput).updateVertex(argThat(likeVertex().withTimId("id3")));
}
use of nl.knaw.huygens.timbuctoo.databaselog.entry.LogEntryFactory in project timbuctoo by HuygensING.
the class DatabaseLogTest method setUp.
@Before
public void setUp() throws Exception {
objectMapper = new ObjectMapper();
logEntryFactory = mock(LogEntryFactory.class);
vertexLogEntry = mock(LogEntry.class);
given(logEntryFactory.createForVertex(any(Vertex.class))).willReturn(vertexLogEntry);
given(logEntryFactory.createForEdge(any(Edge.class))).willReturn(mock(LogEntry.class));
}
use of nl.knaw.huygens.timbuctoo.databaselog.entry.LogEntryFactory in project timbuctoo by HuygensING.
the class DatabaseLogTest method generateIteratesThroughAllVerticesOrderedByModifiedDate.
@Test
public void generateIteratesThroughAllVerticesOrderedByModifiedDate() throws Exception {
String first = "first";
String second = "second";
String third = "third";
GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withTimId(first).withProperty("modified", getChangeStringWithTimestamp(1464346423L)).withProperty("rev", 1)).withVertex(v -> v.withTimId(third).withProperty("modified", getChangeStringWithTimestamp(1464346425L)).withProperty("rev", 1)).withVertex(v -> v.withTimId(second).withProperty("modified", getChangeStringWithTimestamp(1464346424L)).withProperty("rev", 1)).wrap();
DatabaseLog instance = createInstance(graphWrapper);
instance.generate();
InOrder inOrder = inOrder(logEntryFactory);
inOrder.verify(logEntryFactory).createForVertex(argThat(likeVertex().withTimId(first)));
inOrder.verify(logEntryFactory).createForVertex(argThat(likeVertex().withTimId(second)));
inOrder.verify(logEntryFactory).createForVertex(argThat(likeVertex().withTimId(third)));
}
use of nl.knaw.huygens.timbuctoo.databaselog.entry.LogEntryFactory in project timbuctoo by HuygensING.
the class DatabaseLogTest method generateAppendsEachVersionOfAVertexOnlyOnce.
@Test
public void generateAppendsEachVersionOfAVertexOnlyOnce() {
GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withTimId("id1").withProperty("modified", getChangeStringWithTimestamp(1464346423L)).withProperty("rev", 1)).withVertex(v -> v.withTimId("id1").withProperty("modified", getChangeStringWithTimestamp(1464346425L)).withProperty("rev", 2)).withVertex(v -> v.withTimId("id1").withProperty("modified", getChangeStringWithTimestamp(1464346424L)).withProperty("rev", 2)).wrap();
DatabaseLog instance = createInstance(graphWrapper);
instance.generate();
verify(logEntryFactory).createForVertex(argThat(likeVertex().withTimId("id1").withProperty("rev", 1)));
verify(logEntryFactory, times(1)).createForVertex(argThat(likeVertex().withTimId("id1").withProperty("rev", 2)));
}
use of nl.knaw.huygens.timbuctoo.databaselog.entry.LogEntryFactory 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)));
}
Aggregations