use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class Neo4JIndexHandlerTest method findByQuickSearchReturnsAnEmtptyTraversalWhenNoVerticesAreFound.
@Test
public void findByQuickSearchReturnsAnEmtptyTraversalWhenNoVerticesAreFound() {
String id1 = UUID.randomUUID().toString();
String id2 = UUID.randomUUID().toString();
String id3 = UUID.randomUUID().toString();
TinkerPopGraphManager tinkerPopGraphManager = newGraph().withVertex(v -> v.withTimId(id1).withProperty("displayName", "query")).withVertex(v -> v.withTimId(id2).withProperty("displayName", "query2")).withVertex(v -> v.withTimId(id3).withProperty("displayName", "other")).wrap();
Neo4jIndexHandler instance = new Neo4jIndexHandler(tinkerPopGraphManager);
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id1).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id2).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id3).next());
QuickSearch quickSearch = QuickSearch.fromQueryString("queryWithoutResult");
GraphTraversal<Vertex, Vertex> vertices = instance.findByQuickSearch(collection, quickSearch);
assertThat(vertices.map(v -> v.get().value("tim_id")).toList(), is(empty()));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class Neo4JIndexHandlerTest method findByQuickSearchIsCaseInsensitive.
@Test
public void findByQuickSearchIsCaseInsensitive() {
String id1 = UUID.randomUUID().toString();
String id2 = UUID.randomUUID().toString();
String id3 = UUID.randomUUID().toString();
TinkerPopGraphManager tinkerPopGraphManager = newGraph().withVertex(v -> v.withTimId(id1).withProperty("displayName", "query")).withVertex(v -> v.withTimId(id2).withProperty("displayName", "QUERY2")).withVertex(v -> v.withTimId(id3).withProperty("displayName", "notmatching")).wrap();
Neo4jIndexHandler instance = new Neo4jIndexHandler(tinkerPopGraphManager);
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id1).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id2).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id3).next());
QuickSearch quickSearch = QuickSearch.fromQueryString("query*");
GraphTraversal<Vertex, Vertex> vertices = instance.findByQuickSearch(collection, quickSearch);
assertThat(vertices.map(v -> v.get().value("tim_id")).toList(), containsInAnyOrder(id1, id2));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class ListFacetDescriptionTest method filterAddsNoFilterIfTheFacetValueIsNotAListFacetValue.
@Test
public void filterAddsNoFilterIfTheFacetValueIsNotAListFacetValue() {
String value1 = "value1";
List<FacetValue> facetValues = Lists.newArrayList((FacetValue) () -> FACET_NAME);
SearchRequestV2_1 searchRequest = new SearchRequestV2_1();
searchRequest.setFacetValues(facetValues);
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withProperty(PROPERTY, value1).withTimId("1")).withVertex(v -> v.withProperty(PROPERTY, "value2").withTimId("2")).build().traversal().V();
instance.filter(traversal, facetValues);
assertThat(traversal.toList(), containsInAnyOrder(VertexMatcher.likeVertex().withTimId("1"), VertexMatcher.likeVertex().withTimId("2")));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class ListFacetDescriptionTest method filterAddsNoFilterIfTheFacetValuesIsEmpty.
@Test
public void filterAddsNoFilterIfTheFacetValuesIsEmpty() {
String value1 = "value1";
List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList()));
SearchRequestV2_1 searchRequest = new SearchRequestV2_1();
searchRequest.setFacetValues(facetValues);
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withProperty(PROPERTY, value1).withTimId("1")).withVertex(v -> v.withProperty(PROPERTY, "value2").withTimId("2")).build().traversal().V();
instance.filter(traversal, facetValues);
assertThat(traversal.toList(), containsInAnyOrder(VertexMatcher.likeVertex().withTimId("1"), VertexMatcher.likeVertex().withTimId("2")));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class RelatedDatableRangeFacetDescriptionTest method filterAddFiltersTheVertices.
@Test
public void filterAddFiltersTheVertices() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex("target1", v -> v.withTimId("id4").withProperty(PROPERTY_NAME, asSerializedDatable("2015-01"))).withVertex("target2", v -> v.withTimId("id5").withProperty(PROPERTY_NAME, asSerializedDatable("0015-01"))).withVertex("target3", v -> v.withTimId("id6").withProperty(PROPERTY_NAME, asSerializedDatable("0190-01"))).withVertex("source1", v -> v.withTimId("id1").withOutgoingRelation(RELATION, "target1")).withVertex("source2", v -> v.withTimId("id2").withOutgoingRelation(RELATION, "target2")).withVertex("source3", v -> v.withTimId("id3").withOutgoingRelation(RELATION, "target3")).build().traversal().V();
List<FacetValue> facetValues = Lists.newArrayList(new DateRangeFacetValue(FACET_NAME, 101101L, 10001231L));
instance.filter(traversal, facetValues);
assertThat(traversal.toList(), containsInAnyOrder(likeVertex().withTimId("id2"), likeVertex().withTimId("id3")));
}
Aggregations