@Test
    public void g_V_call_barrier_lambda() {
        final String serviceName = "tinker.order";

        final Comparator defaultComparator = Comparator.comparing(Object::toString);

        final TriFunction<ServiceCallContext, TraverserSet<Object>, Map, Iterator<Traverser.Admin<Object>>> lambda =
                (ctx, traverserSet, map) -> {
            final Comparator comparator = (Comparator) map.getOrDefault("comparator", defaultComparator);
            traverserSet.sort(comparator);
            return traverserSet.iterator();
        };

        graph.getServiceRegistry().<Object,Traverser.Admin<Object>>registerLambdaService(serviceName).addBarrierLambda(lambda);

        assertArrayEquals(new String[] {
                "vp[age->27]",
                "vp[age->29]",
                "vp[age->32]",
                "vp[age->35]",
                "vp[lang->java]",
                "vp[lang->java]",
                "vp[name->josh]",
                "vp[name->lop]",
                "vp[name->marko]",
                "vp[name->peter]",
                "vp[name->ripple]",
                "vp[name->vadas]",
                }, toResultStrings(

            g.V().properties().call(serviceName)

        ));

        assertArrayEquals(new String[] {
                "vp[name->vadas]",
                "vp[name->ripple]",
                "vp[name->peter]",
                "vp[name->marko]",
                "vp[name->lop]",
                "vp[name->josh]",
                "vp[lang->java]",
                "vp[lang->java]",
                "vp[age->35]",
                "vp[age->32]",
                "vp[age->29]",
                "vp[age->27]",
                }, toResultStrings(

            g.V().properties().call(serviceName, asMap("comparator", defaultComparator.reversed()))

        ));
    }
Demonstrates registration and usage of a Barrier lambda service. Barrier services collect all upstream input
and produce an iterator of results. Barrier services can reduce, expand or pass-through their input.
tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphServiceTest.java