Search in sources :

Example 6 with IndexHandler

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

the class FulltextIndexChangeListenerTest method onPropertyUpdateRemovesTheOldVertexFromTheIndexBeforeAddingTheNewOne.

@Test
public void onPropertyUpdateRemovesTheOldVertexFromTheIndexBeforeAddingTheNewOne() {
    IndexHandler indexHandler = mock(IndexHandler.class);
    GraphWrapper graphWrapper = newGraph().withVertex("newVertex", v -> v.withProperty("vrecoll_name", "new")).withVertex(v -> v.withProperty("vrecoll_name", "old").withOutgoingRelation("VERSION_OF", "newVertex")).wrap();
    FulltextIndexChangeListener instance = new FulltextIndexChangeListener(indexHandler, graphWrapper);
    Collection collection = new VresBuilder().withVre("thevre", "vre", vre -> vre.withCollection("vrecolls", coll -> coll.withDisplayName(localProperty("vrecoll_name")))).build().getCollection("vrecolls").get();
    Vertex oldVertex = graphWrapper.getGraph().traversal().V().has("vrecoll_name", "old").next();
    Vertex newVertex = graphWrapper.getGraph().traversal().V().has("vrecoll_name", "new").next();
    instance.onPropertyUpdate(collection, Optional.of(oldVertex), newVertex);
    verify(indexHandler).upsertIntoQuickSearchIndex(collection, "new", newVertex, oldVertex);
}
Also used : GraphWrapper(nl.knaw.huygens.timbuctoo.server.GraphWrapper) PropertyTypes.localProperty(nl.knaw.huygens.timbuctoo.model.properties.PropertyTypes.localProperty) IndexHandler(nl.knaw.huygens.timbuctoo.database.tinkerpop.IndexHandler) VresBuilder(nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder) Optional(java.util.Optional) Test(org.junit.Test) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Mockito.mock(org.mockito.Mockito.mock) Mockito.verify(org.mockito.Mockito.verify) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) IndexHandler(nl.knaw.huygens.timbuctoo.database.tinkerpop.IndexHandler) GraphWrapper(nl.knaw.huygens.timbuctoo.server.GraphWrapper) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) VresBuilder(nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder) Test(org.junit.Test)

Example 7 with IndexHandler

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

the class FulltextIndexChangeListenerTest method onCreateAddsItemsToTheIndexOfTheProvidedCollection.

@Test
public void onCreateAddsItemsToTheIndexOfTheProvidedCollection() {
    IndexHandler indexHandler = mock(IndexHandler.class);
    GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withProperty("vrecoll_name", "foo")).wrap();
    FulltextIndexChangeListener instance = new FulltextIndexChangeListener(indexHandler, graphWrapper);
    Collection collection = new VresBuilder().withVre("thevre", "vre", vre -> vre.withCollection("vrecolls", coll -> coll.withDisplayName(localProperty("vrecoll_name")))).build().getCollection("vrecolls").get();
    Vertex vertex = graphWrapper.getGraph().traversal().V().next();
    instance.onCreate(collection, vertex);
    verify(indexHandler).upsertIntoQuickSearchIndex(collection, "foo", vertex, null);
}
Also used : GraphWrapper(nl.knaw.huygens.timbuctoo.server.GraphWrapper) PropertyTypes.localProperty(nl.knaw.huygens.timbuctoo.model.properties.PropertyTypes.localProperty) IndexHandler(nl.knaw.huygens.timbuctoo.database.tinkerpop.IndexHandler) VresBuilder(nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder) Optional(java.util.Optional) Test(org.junit.Test) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Mockito.mock(org.mockito.Mockito.mock) Mockito.verify(org.mockito.Mockito.verify) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) IndexHandler(nl.knaw.huygens.timbuctoo.database.tinkerpop.IndexHandler) GraphWrapper(nl.knaw.huygens.timbuctoo.server.GraphWrapper) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) VresBuilder(nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder) Test(org.junit.Test)

Aggregations

IndexHandler (nl.knaw.huygens.timbuctoo.database.tinkerpop.IndexHandler)7 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)7 Test (org.junit.Test)7 Optional (java.util.Optional)6 TestGraphBuilder.newGraph (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph)6 Mockito.mock (org.mockito.Mockito.mock)6 Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)4 PropertyTypes.localProperty (nl.knaw.huygens.timbuctoo.model.properties.PropertyTypes.localProperty)4 VresBuilder (nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder)4 GraphWrapper (nl.knaw.huygens.timbuctoo.server.GraphWrapper)4 Mockito.verify (org.mockito.Mockito.verify)4 UUID (java.util.UUID)3 Neo4jLuceneEntityFetcher (nl.knaw.huygens.timbuctoo.database.tinkerpop.Neo4jLuceneEntityFetcher)2 TinkerPopGraphManager (nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager)2 VertexMatcher.likeVertex (nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex)2 GraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal)2 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)2 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)2 Matchers.equalTo (org.hamcrest.Matchers.equalTo)2 Matchers.is (org.hamcrest.Matchers.is)2