### Question:
EdgeListFacetDescription extends AbstractFacetDescription { @Override 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(__.inE(values.toArray(new String[values.size()]))); } } } } EdgeListFacetDescription(String facetName, String... relationNames); @Override void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facets); List<String> getValues(Vertex vertex);  }### Answer:
@Test public void filterDoesNotAddFilterToTheGraphTraversalWhenTheFacetOfTheDescriptionIsNotPresent() { GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex(v -> v.withTimId("1")) .withVertex(v -> v.withTimId("2")) .build().traversal().V(); List<FacetValue> facetValues = Lists.newArrayList(); instance.filter(traversal, facetValues); assertThat(traversal.toList(), containsInAnyOrder(VertexMatcher.likeVertex().withTimId("1"), VertexMatcher.likeVertex().withTimId("2"))); }
@Test public void filterAddsAFilterToFilterOutTheNonMatchingVertices() { List<FacetValue> facetValues = Lists.newArrayList( new ListFacetValue(FACET_NAME, Lists.newArrayList(RELATION_NAME))); SearchRequestV2_1 searchRequest = new SearchRequestV2_1(); searchRequest.setFacetValues(facetValues); GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex("v1", v -> v.withTimId("1")) .withVertex("v2", v -> v.withTimId("2").withOutgoingRelation(RELATION_NAME, "v1")) .build().traversal().V(); instance.filter(traversal, facetValues); assertThat(traversal.toList(), contains(VertexMatcher.likeVertex().withTimId("1"))); }
@Test public void filterAddsNoFilterIfTheFacetValuesIsEmpty() { 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.withTimId("1")) .withVertex(v -> v.withTimId("2")) .build().traversal().V(); instance.filter(traversal, facetValues); assertThat(traversal.toList(), containsInAnyOrder(VertexMatcher.likeVertex().withTimId("1"), VertexMatcher.likeVertex().withTimId("2"))); }