Search in sources :

Example 6 with TinkerpopSaver

use of nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerpopSaver in project timbuctoo by HuygensING.

the class TinkerpopSaverTest method addPropertyDescriptionsAddsThePropertyDescriptionsToTheCollection.

@Test
public void addPropertyDescriptionsAddsThePropertyDescriptionsToTheCollection() {
    final TinkerpopSaver instance = new TinkerpopSaver(vres, graphWrapper, VRE_NAME, VRE_NAME, MAX_VERTICES_PER_TRANSACTION, VRE_NAME);
    ImportPropertyDescriptions importPropertyDescriptions = new ImportPropertyDescriptions();
    importPropertyDescriptions.getOrCreate(6).setPropertyName("first");
    importPropertyDescriptions.getOrCreate(5).setPropertyName("second");
    importPropertyDescriptions.getOrCreate(7).setPropertyName("third");
    instance.addPropertyDescriptions(rawCollection, importPropertyDescriptions);
    List<Vertex> properties = graphWrapper.getGraph().traversal().V(rawCollection.id()).out("hasProperty").toList();
    assertThat(properties, hasSize(3));
    assertThat(properties, containsInAnyOrder(likeVertex().withProperty("order", 0).withProperty("id", 6).withProperty("name", "first"), likeVertex().withProperty("order", 1).withProperty("id", 5).withProperty("name", "second"), likeVertex().withProperty("order", 2).withProperty("id", 7).withProperty("name", "third")));
}
Also used : ImportPropertyDescriptions(nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.ImportPropertyDescriptions) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) TinkerpopSaver(nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerpopSaver) Test(org.junit.Test)

Example 7 with TinkerpopSaver

use of nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerpopSaver in project timbuctoo by HuygensING.

the class TinkerpopSaverTest method addEntityAppendsTheNewVertexToThePrevious.

@Test
public void addEntityAppendsTheNewVertexToThePrevious() {
    final TinkerpopSaver instance = new TinkerpopSaver(vres, graphWrapper, VRE_NAME, VRE_NAME, MAX_VERTICES_PER_TRANSACTION, VRE_NAME);
    final Vertex first = instance.addEntity(rawCollection, Maps.newHashMap());
    final Vertex second = instance.addEntity(rawCollection, Maps.newHashMap());
    final Vertex third = instance.addEntity(rawCollection, Maps.newHashMap());
    assertThat(first.vertices(Direction.OUT, NEXT_RAW_ITEM_EDGE_NAME).hasNext(), is(true));
    assertThat(first.vertices(Direction.OUT, NEXT_RAW_ITEM_EDGE_NAME).next(), is(second));
    assertThat(second.vertices(Direction.OUT, NEXT_RAW_ITEM_EDGE_NAME).hasNext(), is(true));
    assertThat(second.vertices(Direction.OUT, NEXT_RAW_ITEM_EDGE_NAME).next(), is(third));
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) TinkerpopSaver(nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerpopSaver) Test(org.junit.Test)

Aggregations

TinkerpopSaver (nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerpopSaver)7 VertexMatcher.likeVertex (nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex)6 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)6 Test (org.junit.Test)6 ImportPropertyDescriptions (nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.ImportPropertyDescriptions)2 IOException (java.io.IOException)1 InvalidFileException (nl.knaw.huygens.timbuctoo.bulkupload.InvalidFileException)1 Importer (nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.Importer)1 ResultReporter (nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.ResultReporter)1 StateMachine (nl.knaw.huygens.timbuctoo.bulkupload.parsingstatemachine.StateMachine)1