### Question:
ANNUtils { public static Set<Integer> selectRandomNeighbors( final int topK, final int numberOfInputs, final int excludeIndex, final Random random) { Set<Integer> randomNeighbors = new HashSet<>(); while(randomNeighbors.size() < topK && randomNeighbors.size() < numberOfInputs - 1) { int index = random.nextInt(numberOfInputs); if (index != excludeIndex) { randomNeighbors.add(index); } } return randomNeighbors; }  static long[] sampleNeighbors(long[] potentialNeighbors, double initialSampleSize, Random random); static Set<Integer> selectRandomNeighbors(
            final int topK, final int numberOfInputs, final int excludeIndex,
            final Random random);  }### Answer:
@Test public void kLessThanInputs() { Set<Integer> integers = ANNUtils.selectRandomNeighbors(3, 5, 1, new Random()); assertThat(integers, Matchers.not(Matchers.hasItem(1))); assertThat(integers, Matchers.hasSize(3)); }
@Test public void kGreaterThanInputs() { Set<Integer> integers = ANNUtils.selectRandomNeighbors(7, 5, 1, new Random()); assertThat(integers, Matchers.not(Matchers.hasItem(1))); assertThat(integers, Matchers.hasSize(4)); }
@Test public void kEqualToInputs() { Set<Integer> integers = ANNUtils.selectRandomNeighbors(5, 5, 3, new Random()); assertThat(integers, Matchers.not(Matchers.hasItem(3))); assertThat(integers, Matchers.hasSize(4)); }