Search in sources :

Example 1 with EntityFinisherHelper

use of nl.knaw.huygens.timbuctoo.core.EntityFinisherHelper in project timbuctoo by HuygensING.

the class TripleImporterIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    // FIXME create stub
    // Timbuctoo needs at least an Admin VRE.
    Vres vres = getVres();
    graphWrapper = newGraph().wrap();
    TinkerPopOperations tinkerPopOperations = new TinkerPopOperations(graphWrapper);
    tinkerPopOperations.saveVre(vres.getVre("Admin"));
    timbuctooActions = TimbuctooActionsStubs.withDataStore(tinkerPopOperations);
    rdfImportSession = RdfImportSession.cleanImportSession(VRE_NAME, tinkerPopOperations, new EntityFinisherHelper());
    instance = new TripleImporter(graphWrapper, VRE_NAME, rdfImportSession);
}
Also used : Vres(nl.knaw.huygens.timbuctoo.model.vre.Vres) EntityFinisherHelper(nl.knaw.huygens.timbuctoo.core.EntityFinisherHelper) TinkerPopOperations(nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerPopOperations) Before(org.junit.Before)

Example 2 with EntityFinisherHelper

use of nl.knaw.huygens.timbuctoo.core.EntityFinisherHelper in project timbuctoo by HuygensING.

the class TinkerPopOperationsTest method finishEntitiesSetsTheAdministrativeProperties.

@Test
public void finishEntitiesSetsTheAdministrativeProperties() {
    TinkerPopGraphManager graphManager = newGraph().wrap();
    TinkerPopOperations instance = forGraphWrapper(graphManager);
    Vre vre = instance.ensureVreExists("vre");
    instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
    vre = instance.loadVres().getVre("vre");
    Vertex e1 = instance.assertEntity(vre, "http://example.org/entity1");
    Vertex e2 = instance.assertEntity(vre, "http://example.org/entity2");
    instance.finishEntities(vre, new EntityFinisherHelper());
    assertThat(graphManager.getGraph().traversal().V(e1.id()).has("tim_id").has("rev").has("modified").has("created").has("types").hasNext(), is(true));
    assertThat(graphManager.getGraph().traversal().V(e2.id()).has("tim_id").has("rev").has("modified").has("created").has("types").hasNext(), is(true));
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) EntityFinisherHelper(nl.knaw.huygens.timbuctoo.core.EntityFinisherHelper) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) VreStubs.minimalCorrectVre(nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre) Test(org.junit.Test)

Example 3 with EntityFinisherHelper

use of nl.knaw.huygens.timbuctoo.core.EntityFinisherHelper in project timbuctoo by HuygensING.

the class TinkerPopOperationsTest method finishEntitiesDuplicatesTheVertices.

@Test
public void finishEntitiesDuplicatesTheVertices() {
    TinkerPopGraphManager graphManager = newGraph().wrap();
    TinkerPopOperations instance = forGraphWrapper(graphManager);
    Vre vre = instance.ensureVreExists("vre");
    instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
    vre = instance.loadVres().getVre("vre");
    Vertex orig = instance.assertEntity(vre, "http://example.org/entity1");
    instance.finishEntities(vre, new EntityFinisherHelper());
    assertThat(orig.edges(Direction.OUT, VERSION_OF).hasNext(), is(true));
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) EntityFinisherHelper(nl.knaw.huygens.timbuctoo.core.EntityFinisherHelper) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) VreStubs.minimalCorrectVre(nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre) Test(org.junit.Test)

Example 4 with EntityFinisherHelper

use of nl.knaw.huygens.timbuctoo.core.EntityFinisherHelper in project timbuctoo by HuygensING.

the class TinkerPopOperationsTest method finishEntitiesCallsTheChangeListener.

@Test
public void finishEntitiesCallsTheChangeListener() {
    ChangeListener changeListener = mock(ChangeListener.class);
    TinkerPopOperations instance = TinkerPopOperationsStubs.forChangeListenerMock(changeListener);
    Vre vre = instance.ensureVreExists("vre");
    instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
    vre = instance.loadVres().getVre("vre");
    Collection defaultCollection = vre.getCollectionForTypeName(defaultEntityTypeName(vre));
    Vertex orig = instance.assertEntity(vre, "http://example.org/entity1");
    instance.finishEntities(vre, new EntityFinisherHelper());
    Vertex duplicate = orig.vertices(Direction.OUT, VERSION_OF).next();
    verify(changeListener).onCreate(eq(defaultCollection), eq(duplicate));
    verify(changeListener).onAddToCollection(eq(defaultCollection), eq(Optional.empty()), eq(duplicate));
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) EntityFinisherHelper(nl.knaw.huygens.timbuctoo.core.EntityFinisherHelper) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) VreStubs.minimalCorrectVre(nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre) CreateCollection(nl.knaw.huygens.timbuctoo.core.dto.CreateCollection) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) ChangeListener(nl.knaw.huygens.timbuctoo.database.tinkerpop.changelistener.ChangeListener) TinkerPopOperationsStubs.forGraphMappingsAndChangeListener(nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerPopOperationsStubs.forGraphMappingsAndChangeListener) Test(org.junit.Test)

Aggregations

EntityFinisherHelper (nl.knaw.huygens.timbuctoo.core.EntityFinisherHelper)4 Vre (nl.knaw.huygens.timbuctoo.model.vre.Vre)3 VreStubs.minimalCorrectVre (nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre)3 VertexMatcher.likeVertex (nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex)3 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)3 Test (org.junit.Test)3 TinkerPopGraphManager (nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager)2 CreateCollection (nl.knaw.huygens.timbuctoo.core.dto.CreateCollection)1 Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)1 TinkerPopOperations (nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerPopOperations)1 TinkerPopOperationsStubs.forGraphMappingsAndChangeListener (nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerPopOperationsStubs.forGraphMappingsAndChangeListener)1 ChangeListener (nl.knaw.huygens.timbuctoo.database.tinkerpop.changelistener.ChangeListener)1 Vres (nl.knaw.huygens.timbuctoo.model.vre.Vres)1 Before (org.junit.Before)1