StaticRegexGeocoderService implements GeocoderService { public GetLocationResult[] getLocation(List<String> location, int maxAlternatives, Locale ignore) { GetLocationResult result = null; for (StaticRegexGeocoderLocationInfo test : geocoderInfo.getLocations()) { result = getLocation(test, location); if (null != result) { break; } } if (null != result) { return new GetLocationResult[]{result}; } return null; }  String getName(); @Api void setName(String name); @Api void setGeocoderInfo(StaticRegexGeocoderInfo geocoderInfo); CoordinateReferenceSystem getCrs(); GetLocationResult[] getLocation(List<String> location, int maxAlternatives, Locale ignore);  }
@Test public void testGetOneLocationShort() throws Exception { List<String> list = new ArrayList<String>(); GetLocationResult result; list.clear(); list.add("bla"); result = service.getLocation(booischotShort, list); Assert.assertNull(result); list.clear(); list.add("Booischot"); result = service.getLocation(booischotShort, list); Assert.assertNotNull(result); list.clear(); list.add("booischot"); result = service.getLocation(booischotShort, list); Assert.assertNotNull(result); list.clear(); list.add("Booischot"); list.add("more"); result = service.getLocation(booischotShort, list); Assert.assertNull(result); list.clear(); list.add("xbooischot"); result = service.getLocation(booischotShort, list); Assert.assertNull(result); list.clear(); list.add("booischotx"); result = service.getLocation(booischotShort, list); Assert.assertNull(result); }
@Test public void testGetOneLocationNormal() throws Exception { List<String> list = new ArrayList<String>(); GetLocationResult result; list.clear(); list.add("belgium"); list.add("antwerp"); list.add("booischot"); result = service.getLocation(booischot, list); Assert.assertNotNull(result); list.clear(); list.add("België"); list.add("Antwerpen"); list.add("Booischot"); result = service.getLocation(booischot, list); Assert.assertNotNull(result); list.clear(); list.add("Antwerpen"); list.add("Booischot"); result = service.getLocation(booischot, list); Assert.assertNull(result); list.clear(); list.add("België"); list.add("Antwerpen"); list.add("Booischot"); list.add("Broekmansstraat"); result = service.getLocation(booischot, list); Assert.assertNotNull(result); list.clear(); list.add("België"); list.add("Booischot"); result = service.getLocation(booischot, list); Assert.assertNotNull(result); list.clear(); list.add("België"); list.add("Booischot"); list.add("Broekmansstraat"); result = service.getLocation(booischot, list); Assert.assertNotNull(result); list.clear(); list.add("België"); result = service.getLocation(booischot, list); Assert.assertNull(result); }
@Test public void testGetOneLocationStrict() throws Exception { List<String> list = new ArrayList<String>(); GetLocationResult result; list.clear(); list.add("België"); list.add("Antwerpen"); list.add("Booischot"); result = service.getLocation(booischotStrict, list); Assert.assertNotNull(result); list.clear(); list.add("Antwerpen"); list.add("Booischot"); result = service.getLocation(booischotStrict, list); Assert.assertNull(result); list.clear(); list.add("België"); list.add("Antwerpen"); list.add("Booischot"); list.add("Broekmansstraat"); result = service.getLocation(booischotStrict, list); Assert.assertNull(result); list.clear(); list.add("België"); list.add("Booischot"); result = service.getLocation(booischotStrict, list); Assert.assertNotNull(result); list.clear(); list.add("België"); result = service.getLocation(booischotStrict, list); Assert.assertNull(result); }