### Question:
BorderingDistanceMetric implements SpatialDistanceMetric { @Override public List<Neighbor> getNeighbors(Geometry g, int maxNeighbors) { return getNeighbors(g, maxNeighbors, Double.MAX_VALUE); } BorderingDistanceMetric(SpatialDataDao dao, String layer); @Override void setValidConcepts(TIntSet concepts); @Override void enableCache(boolean enable); @Override String getName(); @Override double distance(Geometry g1, Geometry g2); @Override float[][] distance(List<Geometry> rowGeometries, List<Geometry> colGeometries); @Override float[][] distance(List<Geometry> geometries); @Override List<Neighbor> getNeighbors(Geometry g, int maxNeighbors); @Override List<Neighbor> getNeighbors(Geometry g, int maxNeighbors, double maxDistance); void setBufferWidth(double bufferWidth); void setMaxSteps(int maxSteps); void setForceContains(boolean forceContains);  }### Answer:
@Test public void testKnn() throws DaoException { List<SpatialDistanceMetric.Neighbor> neighbors = metric.getNeighbors(g("Minnesota"), 100); for (int i = 0; i < neighbors.size(); i++) { SpatialDistanceMetric.Neighbor n = neighbors.get(i); String name = n(n.conceptId); if (i == 0) { assertEquals(name, "Minnesota"); } else if (i <= 4) { assertTrue(Arrays.asList("North Dakota", "Iowa", "Wisconsin", "South Dakota").contains(name)); } } SpatialDistanceMetric.Neighbor last = neighbors.get(neighbors.size() - 1); assertEquals(8.0, last.distance, 0.01); assertEquals("Maine", n(last.conceptId)); }