@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"))); }
@Override @SuppressWarnings("unchecked") public void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facets) { Optional<FacetValue> facetValue = facets.stream().filter(facet -> Objects.equals(facet.getName(), facetName)).findFirst(); if (facetValue.isPresent()) { FacetValue value = facetValue.get(); if (value instanceof ListFacetValue) { List<String> values = ((ListFacetValue) value).getValues(); if (!values.isEmpty()) { graphTraversal.where(__.has(propertyName, P.test((o1, o2) -> { List<String> possibileValues = (List<String>) o2; return possibileValues.contains(parser.parse("" + o1)); }, values))); } } } }
ListFacetDescription extends AbstractFacetDescription { @Override @SuppressWarnings("unchecked") public void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facets) { Optional<FacetValue> facetValue = facets.stream().filter(facet -> Objects.equals(facet.getName(), facetName)).findFirst(); if (facetValue.isPresent()) { FacetValue value = facetValue.get(); if (value instanceof ListFacetValue) { List<String> values = ((ListFacetValue) value).getValues(); if (!values.isEmpty()) { graphTraversal.where(__.has(propertyName, P.test((o1, o2) -> { List<String> possibileValues = (List<String>) o2; return possibileValues.contains(parser.parse("" + o1)); }, values))); } } } } }
ListFacetDescription extends AbstractFacetDescription { @Override @SuppressWarnings("unchecked") public void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facets) { Optional<FacetValue> facetValue = facets.stream().filter(facet -> Objects.equals(facet.getName(), facetName)).findFirst(); if (facetValue.isPresent()) { FacetValue value = facetValue.get(); if (value instanceof ListFacetValue) { List<String> values = ((ListFacetValue) value).getValues(); if (!values.isEmpty()) { graphTraversal.where(__.has(propertyName, P.test((o1, o2) -> { List<String> possibileValues = (List<String>) o2; return possibileValues.contains(parser.parse("" + o1)); }, values))); } } } } ListFacetDescription(String facetName, String propertyName, PropertyParser parser); }
ListFacetDescription extends AbstractFacetDescription { @Override @SuppressWarnings("unchecked") public void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facets) { Optional<FacetValue> facetValue = facets.stream().filter(facet -> Objects.equals(facet.getName(), facetName)).findFirst(); if (facetValue.isPresent()) { FacetValue value = facetValue.get(); if (value instanceof ListFacetValue) { List<String> values = ((ListFacetValue) value).getValues(); if (!values.isEmpty()) { graphTraversal.where(__.has(propertyName, P.test((o1, o2) -> { List<String> possibileValues = (List<String>) o2; return possibileValues.contains(parser.parse("" + o1)); }, values))); } } } } ListFacetDescription(String facetName, String propertyName, PropertyParser parser); @Override @SuppressWarnings("unchecked") void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facets); }
ListFacetDescription extends AbstractFacetDescription { @Override @SuppressWarnings("unchecked") public void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facets) { Optional<FacetValue> facetValue = facets.stream().filter(facet -> Objects.equals(facet.getName(), facetName)).findFirst(); if (facetValue.isPresent()) { FacetValue value = facetValue.get(); if (value instanceof ListFacetValue) { List<String> values = ((ListFacetValue) value).getValues(); if (!values.isEmpty()) { graphTraversal.where(__.has(propertyName, P.test((o1, o2) -> { List<String> possibileValues = (List<String>) o2; return possibileValues.contains(parser.parse("" + o1)); }, values))); } } } } ListFacetDescription(String facetName, String propertyName, PropertyParser parser); @Override @SuppressWarnings("unchecked") void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facets);  }