@Test
    public void shouldGetLegallyPositiveEdgeLabels() {
        GraphFilter graphFilter = new GraphFilter();
        assertFalse(graphFilter.hasEdgeFilter());
        assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT));
        assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN));
        assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH));
        //
        graphFilter = new GraphFilter();
        graphFilter.setEdgeFilter(__.outE("created"));
        assertTrue(graphFilter.hasEdgeFilter());
        assertEquals(Collections.singleton("created"), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT));
        assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN));
        assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH));
        //
        graphFilter = new GraphFilter();
        graphFilter.setEdgeFilter(__.outE());
        assertTrue(graphFilter.hasEdgeFilter());
        assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT));
        assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN));
        assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH));
        //
        graphFilter = new GraphFilter();
        graphFilter.setEdgeFilter(__.<Vertex>outE("created").has("weight", 32));
        assertTrue(graphFilter.hasEdgeFilter());
        assertEquals(Collections.singleton("created"), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT));
        assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN));
        assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH));
        //
        graphFilter = new GraphFilter();
        graphFilter.setEdgeFilter(__.<Vertex>identity().outE("created"));
        assertTrue(graphFilter.hasEdgeFilter());
        assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT));
        assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN));
        assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH));
        //
        graphFilter = new GraphFilter();
        graphFilter.setEdgeFilter(__.bothE());
        assertTrue(graphFilter.hasEdgeFilter());
        assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT));
        assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN));
        assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH));
        //
        graphFilter = new GraphFilter();
        graphFilter.setEdgeFilter(__.<Vertex>bothE().has("weight", 32));
        assertTrue(graphFilter.hasEdgeFilter());
        assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT));
        assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN));
        assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH));
        //
        graphFilter = new GraphFilter();
        graphFilter.setEdgeFilter(__.<Vertex>bothE().limit(0));
        assertTrue(graphFilter.hasEdgeFilter());
        assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT));
        assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN));
        assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH));
        //
        graphFilter = new GraphFilter();
        graphFilter.setEdgeFilter(__.<Vertex>bothE("created").has("weight", 32));
        assertTrue(graphFilter.hasEdgeFilter());
        assertEquals(Collections.singleton("created"), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT));
        assertEquals(Collections.singleton("created"), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN));
        assertEquals(Collections.singleton("created"), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH));
        //
        graphFilter = new GraphFilter();
        graphFilter.setEdgeFilter(__.union(__.outE("created"), __.inE("likes")));
        assertTrue(graphFilter.hasEdgeFilter());
        assertEquals(Collections.singleton("created"), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT));
        assertEquals(Collections.singleton("likes"), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN));
        assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH));
        //
        graphFilter = new GraphFilter();
        graphFilter.setEdgeFilter(__.union(__.outE("created"), __.inE("likes", "created")));
        assertTrue(graphFilter.hasEdgeFilter());
        assertEquals(Collections.singleton("created"), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT));
        assertEquals(new HashSet<>(Arrays.asList("likes", "created")), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN));
        assertEquals(Collections.singleton("created"), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH));
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilterTest.java