@Test
    @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
    @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY)
    @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
    @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_PROPERTY)
    public void shouldHandleBothEdgesGraphFilterOnSelfLoop() {
        assertEquals(0l, IteratorUtils.count(graph.vertices()));
        assertEquals(0l, IteratorUtils.count(graph.edges()));

        // these vertex label, edge label, and property names/values were copied from existing tests
        StarGraph starGraph = StarGraph.open();
        Vertex vertex = starGraph.addVertex(T.label, "person", "name", "furnace");
        Edge edge = vertex.addEdge("self", vertex);
        edge.property("acl", "private");

        // traversing a self-loop should yield the edge once for inE/outE
        // and the edge twice for bothE (one edge emitted two times, not two edges)
        assertEquals(1L, IteratorUtils.count(starGraph.traversal().V().inE()));
        assertEquals(1L, IteratorUtils.count(starGraph.traversal().V().outE()));
        assertEquals(2L, IteratorUtils.count(starGraph.traversal().V().bothE()));
        
        // Try a filter that retains BOTH
        GraphFilter graphFilter = new GraphFilter();
        graphFilter.setEdgeFilter(__.bothE("self"));
        starGraph = starGraph.applyGraphFilter(graphFilter).get();

        // Retest traversal counts after filtering
        assertEquals(1L, IteratorUtils.count(starGraph.traversal().V().inE()));
        assertEquals(1L, IteratorUtils.count(starGraph.traversal().V().outE()));
        assertEquals(2L, IteratorUtils.count(starGraph.traversal().V().bothE()));
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java