GeometryFilterFactory { public static GeometryFilter create(Geometry region) { if (region == null) { return new NoConstraintGeometryFilter(); } else if (region instanceof Polygon) { return new PolygonGeometryFilter(region); } throw new IllegalArgumentException("Unsupported region geometry: " + region.toString()); }  static GeometryFilter create(Geometry region);  }
@Test public void testCreate_noGeometrySupplied() { final GeometryFilter filter = GeometryFilterFactory.create(null); assertTrue(filter instanceof NoConstraintGeometryFilter); }
@Test public void testCreate_withPolygon() throws ConversionException { final Geometry geometry = jtsGeometryConverter.parse("POLYGON((5 1, 5 2, 6 2, 6 1, 5 1))"); final GeometryFilter filter = GeometryFilterFactory.create(geometry); assertTrue(filter instanceof PolygonGeometryFilter); }
@Test public void testCreate_withUnsupportedGeometry() throws ConversionException { final Geometry geometry = jtsGeometryConverter.parse("POINT(5 1)"); try { GeometryFilterFactory.create(geometry); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { } }