### Question:
JTSUtils { static Polygon buildPolygon(TDWay way) { Coordinate[] coordinates = JTSUtils.toCoordinates(way); return GEOMETRY_FACTORY.createPolygon(GEOMETRY_FACTORY.createLinearRing(coordinates), null); } private  JTSUtils(); static Coordinate toCoordinate(TDNode node); static Coordinate[] toCoordinates(TDWay way); static Geometry toJtsGeometry(TDWay way, List<TDWay> innerWays);  }### Answer:
@Test public void testBuildInvalidPolygon() { String testfile = "invalid-polygon.wkt"; List<TDWay> ways = MockingUtils.wktPolygonToWays(testfile); Polygon polygon = JTSUtils.buildPolygon(ways.get(0)); Geometry expected = MockingUtils.readWKTFile(testfile); Assert.isTrue(!polygon.isValid()); Assert.equals(expected, polygon); }
@Test public void testBuildInValidPolygonWith2InnerRings() { String testfile = "invalid-polygon-2-inner-rings.wkt"; List<TDWay> ways = MockingUtils.wktPolygonToWays(testfile); Polygon polygon = JTSUtils.buildPolygon(ways.get(0), ways.subList(1, ways.size())); Geometry expected = MockingUtils.readWKTFile(testfile); Assert.isTrue(!polygon.isValid()); Assert.equals(expected, polygon); }
@Test public void testBuildValidPolygon() { String testfile = "valid-polygon.wkt"; List<TDWay> ways = MockingUtils.wktPolygonToWays(testfile); Polygon polygon = JTSUtils.buildPolygon(ways.get(0)); Geometry expected = MockingUtils.readWKTFile(testfile); Assert.isTrue(polygon.isValid()); Assert.equals(expected, polygon); }
@Test public void testBuildValidPolygonWith2InnerRings() { String testfile = "valid-polygon-2-inner-rings.wkt"; List<TDWay> ways = MockingUtils.wktPolygonToWays(testfile); Polygon polygon = JTSUtils.buildPolygon(ways.get(0), ways.subList(1, ways.size())); Geometry expected = MockingUtils.readWKTFile(testfile); Assert.isTrue(polygon.isValid()); Assert.equals(expected, polygon); }