### Question:
ConstantDegreeDistribution implements DegreeDistribution { @Override public Sample createSample(final int size, final Random random) { return new Sample() { private int nextIndex = 0; @Override public int getNextDegree() { return degree; } @Override public int getNextIndex() { return nextIndex++; } }; } ConstantDegreeDistribution(int degree); @Override Sample createSample(final int size, final Random random);  }### Answer:
@Test public void constantSampleIsCorrect() throws Exception { ConstantDegreeDistribution distro = new ConstantDegreeDistribution(1); int n = 10; Random random = new Random(); DegreeDistribution.Sample sample = distro.createSample(n, random); Set<Integer> indexes = new HashSet<>(); for (int i = 0; i < n; i++) { assertEquals(1, sample.getNextDegree()); indexes.add(sample.getNextIndex()); } assertEquals(n, indexes.size()); }