@Test
    public void shouldSelectSubsetsCorrectly() {
        final List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            list.add(i);
        }
        for(int i=0; i<100; i++) {
            List<Integer> result;
            result = (List) __.inject(list).unfold().sample(i).toList();
            assertEquals(i, result.size());
            assertEquals(i, new HashSet<>(result).size());
            assertTrue(list.containsAll(result));
        }
    }
@author Daniel Kuppitz (http://gremlin.guru)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/SampleGlobalStepTest.java