use of nl.knaw.huygens.timbuctoo.database.tinkerpop.Neo4jLuceneEntityFetcher in project timbuctoo by HuygensING.
the class Neo4jLuceneEntityFetcherTest method getEntityRetrievesTheLatestFromTheGraphEvenIfTheIndexIsNotUpToDate.
@Test
public void getEntityRetrievesTheLatestFromTheGraphEvenIfTheIndexIsNotUpToDate() {
final UUID timId = UUID.randomUUID();
final String collectionName = "things";
TinkerPopGraphManager graphManager = newGraph().withVertex("latest", v -> v.withTimId(timId).isLatest(true)).withVertex(v -> v.withTimId(timId).isLatest(false).withOutgoingRelation("VERSION_OF", "latest")).wrap();
GraphTraversal<Vertex, Vertex> secondLatestVertexT = graphManager.getGraph().traversal().V().has("tim_id", timId.toString()).has("isLatest", false);
given(indexHandler.findById(timId)).willReturn(Optional.of(secondLatestVertexT.next()));
Neo4jLuceneEntityFetcher instance = new Neo4jLuceneEntityFetcher(graphManager, indexHandler);
GraphTraversalSource traversal = graphManager.getGraph().traversal();
GraphTraversal<Vertex, Vertex> entityT = instance.getEntity(traversal, timId, null, collectionName);
assertThat(entityT.hasNext(), is(true));
assertThat(entityT.next(), is(likeVertex().withTimId(timId).withProperty("isLatest", true)));
}
use of nl.knaw.huygens.timbuctoo.database.tinkerpop.Neo4jLuceneEntityFetcher in project timbuctoo by HuygensING.
the class Neo4jLuceneEntityFetcherTest method getEntityRetrievesTheVertexDirectFromTheDatabaseWhenTheIndexDoesNotContainIt.
@Test
public void getEntityRetrievesTheVertexDirectFromTheDatabaseWhenTheIndexDoesNotContainIt() {
final UUID timId = UUID.randomUUID();
final String things = "things";
TinkerPopGraphManager graphManager = newGraph().withVertex("latest", v -> v.withTimId(timId).isLatest(true)).withVertex(v -> v.withTimId(timId).isLatest(false).withOutgoingRelation("VERSION_OF", "latest")).wrap();
given(indexHandler.findById(timId)).willReturn(Optional.empty());
Neo4jLuceneEntityFetcher instance = new Neo4jLuceneEntityFetcher(graphManager, indexHandler);
GraphTraversalSource traversal = graphManager.getGraph().traversal();
GraphTraversal<Vertex, Vertex> entityT = instance.getEntity(traversal, timId, null, things);
assertThat(entityT.next().value("tim_id"), equalTo(timId.toString()));
}
Aggregations