GeoHashExtensions { public static List<String> getAllAdjacentAreasList(final String geohash) { if ((geohash == null) || geohash.isEmpty()) { throw new IllegalArgumentException("Argument geohash should not be null."); } final List<String> adjacentAreas = new ArrayList<>(); final String top = GeoHashExtensions.getAdjacent(geohash, Adjacent.TOP); final String bottom = GeoHashExtensions.getAdjacent(geohash, Adjacent.BOTTOM); final String right = GeoHashExtensions.getAdjacent(geohash, Adjacent.RIGHT); final String left = GeoHashExtensions.getAdjacent(geohash, Adjacent.LEFT); final String topleft = GeoHashExtensions.getAdjacent(left, Adjacent.TOP); final String topright = GeoHashExtensions.getAdjacent(right, Adjacent.TOP); final String bottomright = GeoHashExtensions.getAdjacent(right, Adjacent.BOTTOM); final String bottomleft = GeoHashExtensions.getAdjacent(left, Adjacent.BOTTOM); adjacentAreas.add(geohash); adjacentAreas.add(top); adjacentAreas.add(topright); adjacentAreas.add(right); adjacentAreas.add(bottomright); adjacentAreas.add(bottom); adjacentAreas.add(bottomleft); adjacentAreas.add(left); adjacentAreas.add(topleft); return adjacentAreas; }  static double[] decode(final String geohash); static double[] decodeAndRound(final String geohash); static String encode(final double latitude, final double longitude); static String getAdjacent(final String geohash, final String direction); static String getAdjacent(final String geohash, final String... directions); static List<String> getAllAdjacentAreasList(final String geohash); static Map<String, String> getAllAdjacentAreasMap(final String geohash); static FirstAndSecondRingRegion getFirstAndSecondRingRegion(final String geohash); static FirstRingRegion getFirstRingRegion(final String geohash); static double getLatitude(final String geohash); static double getLongitude(final String geohash); static Map<String, String> getTwentyFiveAreasMap(final String geohash);  }
@Test public void testGetAllAdjacentAreasList() { List<String> expected; List<String> actual; String geohash; String subGeohash; geohash = GeoHashExtensions.encode(53.5526394, 10.0067103); subGeohash = geohash.substring(0, 7); actual = GeoHashExtensions.getAllAdjacentAreasList(subGeohash); expected = ListFactory.newArrayList("u1x0esy", "u1x0etn", "u1x0etp", "u1x0esz", "u1x0esx", "u1x0esw", "u1x0est", "u1x0esv", "u1x0etj"); for (int i = 0; i < actual.size(); i++) { assertEquals(expected.get(i), actual.get(i)); } }
@Test(expectedExceptions = IllegalArgumentException.class) public final void testGetAllAdjacentAreasListNullValue() { GeoHashExtensions.getAllAdjacentAreasList(null); }
@Test(expectedExceptions = IllegalArgumentException.class) public final void testGetAllAdjacentAreasListWithEmptyValue() { GeoHashExtensions.getAllAdjacentAreasList(""); }