use of nl.knaw.huygens.timbuctoo.search.FacetValue in project timbuctoo by HuygensING.
the class ListFacetDescriptionTest method filterLetsTheParserParseEachDatabaseValue.
@Test
public void filterLetsTheParserParseEachDatabaseValue() {
String value1 = "value1";
List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList(value1)));
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);
// needed to verify the parser
traversal.toList();
verify(propertyParser).parse("value1");
verify(propertyParser).parse("value2");
}
use of nl.knaw.huygens.timbuctoo.search.FacetValue in project timbuctoo by HuygensING.
the class ListFacetDescriptionTest method filterAddsAFilterToFilterOutTheNonMatchingVertices.
@Test
public void filterAddsAFilterToFilterOutTheNonMatchingVertices() {
String value1 = "value1";
List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList(value1)));
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(), contains(VertexMatcher.likeVertex().withTimId("1")));
}
use of nl.knaw.huygens.timbuctoo.search.FacetValue in project timbuctoo by HuygensING.
the class MultiValueListFacetDescriptionTest method filterAddsAFilterThatChecksIfTheVerticesContainOnOfTheValues.
@Test
public void filterAddsAFilterThatChecksIfTheVerticesContainOnOfTheValues() {
String value3 = "value3";
String value4 = "value4";
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_NAME, serializedListOf("value1", "value2"))).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_NAME, serializedListOf("value2", value3))).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_NAME, serializedListOf("value1", value4))).build().traversal().V();
List<String> values = Lists.newArrayList(value3, value4);
List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, values));
instance.filter(traversal, facetValues);
assertThat(traversal.toList(), containsInAnyOrder(likeVertex().withTimId("id2"), likeVertex().withTimId("id3")));
}
use of nl.knaw.huygens.timbuctoo.search.FacetValue in project timbuctoo by HuygensING.
the class MultiValueListFacetDescriptionTest method filterDoesNotAddAFilterWhenTheFacetValueContainsNoValues.
@Test
public void filterDoesNotAddAFilterWhenTheFacetValueContainsNoValues() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_NAME, serializedListOf("value1", "value2"))).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_NAME, serializedListOf("value2", "value3"))).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_NAME, serializedListOf("value1", "value3", "value4"))).build().traversal().V();
List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList()));
instance.filter(traversal, facetValues);
assertThat(traversal.toList(), containsInAnyOrder(likeVertex().withTimId("id1"), likeVertex().withTimId("id2"), likeVertex().withTimId("id3")));
}
use of nl.knaw.huygens.timbuctoo.search.FacetValue in project timbuctoo by HuygensING.
the class MultiValueListFacetDescriptionTest method filterFiltersAllTheVerticesThatDoNotContainTheFacetValue.
@Test
public void filterFiltersAllTheVerticesThatDoNotContainTheFacetValue() {
String value1 = "value1";
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_NAME, serializedListOf(value1, "value2"))).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_NAME, serializedListOf("value2", "value3"))).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_NAME, serializedListOf(value1, "value3", "value4"))).build().traversal().V();
List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList(value1)));
instance.filter(traversal, facetValues);
List<Vertex> actual = traversal.toList();
assertThat(actual, containsInAnyOrder(likeVertex().withTimId("id1"), likeVertex().withTimId("id3")));
}
Aggregations