### Question:
AnalyzeUtils { static public List<Fragment> getSampleFragments(List<Fragment> fragments, RequestContext context) { int listSize = fragments.size(); int maxSize = context.getStatsMaxFragments(); List<Fragment> samplingList = new ArrayList<Fragment>(); BitSet bitSet; if (maxSize == 0) { return fragments; } LOG.debug("fragments list has " + listSize + " fragments, maxFragments = " + maxSize); bitSet = generateSamplingBitSet(listSize, maxSize); for (int i = 0; i < listSize; ++i) { if (bitSet.get(i)) { samplingList.add(fragments.get(i)); } } return samplingList; }  static List<Fragment> getSampleFragments(List<Fragment> fragments,
                                                    RequestContext context); static BitSet generateSamplingBitSet(int poolSize, int sampleSize);  }### Answer:
@Test public void getSampleFragments() throws Exception { runGetSampleFragmentsTest(4, 100, 4, new int[] {0, 1, 2, 3}); runGetSampleFragmentsTest(4, 2, 2, new int[]{0, 3}); runGetSampleFragmentsTest(10, 2, 2, new int[]{0, 6}); runGetSampleFragmentsTest(10, 3, 3, new int[]{0, 4, 8}); runGetSampleFragmentsTest(10, 9, 9, new int[]{0, 1, 2, 4, 5, 6, 7, 8, 9 }); runGetSampleFragmentsTest(15, 10, 10, new int[]{0, 2, 3, 4, 6, 7, 8, 10, 12, 14}); runGetSampleFragmentsTest(1000, 10, 10, new int[]{0, 101, 202, 303, 404, 505, 606, 707, 808, 909}); runGetSampleFragmentsTest(100, 65, 65, new int[]{0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, 26, 28, 29, 30, 32, 33, 34, 36, 37, 38, 40, 41, 42, 44, 45, 46, 48, 49, 50, 52, 53, 54, 56, 57, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98 }); runGetSampleFragmentsTest(10, 0, 10, new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); }