### Question:
Centers implements Iterable<RealVector> { public Distance getDistance(RealVector point) { double min = Double.POSITIVE_INFINITY; int index = -1; for (int i = 0; i < centers.size(); i++) { RealVector c = centers.get(i); double distance = c.getDistance(point); double distanceSquared = distance * distance; if (distanceSquared < min) { min = distanceSquared; index = i; } min = Math.min(min, distance * distance); } return new Distance(min, index); } Centers(RealVector... points);  Centers(Iterable<RealVector> points); int size(); RealVector get(int index); boolean contains(RealVector vec); @Override Iterator<RealVector> iterator(); Centers extendWith(RealVector point); Distance getDistance(RealVector point); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testSingleton() throws Exception { Centers centers = new Centers(a); assertEquals(0.0, centers.getDistance(a).getSquaredDistance(), THRESH); assertEquals(5.0, centers.getDistance(b).getSquaredDistance(), THRESH); assertEquals(17.0, centers.getDistance(c).getSquaredDistance(), THRESH); assertEquals(0, centers.getDistance(b).getClosestCenterId()); }
@Test public void testTwo() throws Exception { Centers centers = new Centers(a, b); assertEquals(0.0, centers.getDistance(a).getSquaredDistance(), THRESH); assertEquals(0.0, centers.getDistance(b).getSquaredDistance(), THRESH); assertEquals(8.0, centers.getDistance(c).getSquaredDistance(), THRESH); assertEquals(1, centers.getDistance(c).getClosestCenterId()); assertEquals(0, centers.getDistance(a).getClosestCenterId()); }