use of nl.knaw.huygens.timbuctoo.server.GraphWrapper in project timbuctoo by HuygensING.
the class FulltextIndexChangeListenerTest method onCreateHandlesWwDocumentsUsingCustomLogic.
@Test
public void onCreateHandlesWwDocumentsUsingCustomLogic() {
IndexHandler indexHandler = mock(IndexHandler.class);
GraphWrapper graphWrapper = newGraph().withVertex("doc", v -> v.withProperty("wwdocument_name", "foo").withOutgoingRelation("isCreatedBy", "authorA", r -> r.withAccepted("wwrelation", true).withIsLatest(true)).withOutgoingRelation("isCreatedBy", "authorB", r -> r.withAccepted("wwrelation", true).withIsLatest(true))).withVertex("authorA", v -> v.withProperty("wwperson_name", "authorA")).withVertex("authorB", v -> v.withProperty("wwperson_name", "authorB")).wrap();
FulltextIndexChangeListener instance = new FulltextIndexChangeListener(indexHandler, graphWrapper);
Collection collection = new VresBuilder().withVre("womenwriters", "ww", vre -> vre.withCollection("wwdocuments", coll -> coll.withDisplayName(localProperty("wwdocument_name"))).withCollection("wwpersons", coll -> coll.withDisplayName(localProperty("wwperson_name")))).build().getCollection("wwdocuments").get();
Vertex vertex = graphWrapper.getGraph().traversal().V().next();
instance.onCreate(collection, vertex);
verify(indexHandler).upsertIntoQuickSearchIndex(collection, "authorA; authorB foo", vertex, null);
}
use of nl.knaw.huygens.timbuctoo.server.GraphWrapper in project timbuctoo by HuygensING.
the class DatabaseFixerTest method fixSetsTheAcceptedPropertiesToTrue.
@Test
public void fixSetsTheAcceptedPropertiesToTrue() {
UUID rel1Id = UUID.fromString("ff65089c-2ded-4af0-95e7-0476979f96b8");
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)).withAccepted("vrerel", false))).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).withProperty("vrerel_accepted", true), likeEdge().withId(rel1Id.toString()).withProperty("rev", 2).withProperty("vrerel_accepted", false)));
}
use of nl.knaw.huygens.timbuctoo.server.GraphWrapper 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.server.GraphWrapper 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.server.GraphWrapper 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)));
}
Aggregations