### Question:
JTSUtils { public static Geometry toJtsGeometry(TDWay way, List<TDWay> innerWays) { if (way == null) { LOGGER.warning("way is null"); return null; } if (way.isValidClosedLine()) { if (way.isForcePolygonLine()) { return buildMultiLineString(way, innerWays); } Polygon polygon = buildPolygon(way, innerWays); if (polygon.isValid()) { return polygon; } return repairInvalidPolygon(polygon); } return buildLineString(way); } private  JTSUtils(); static Coordinate toCoordinate(TDNode node); static Coordinate[] toCoordinates(TDWay way); static Geometry toJtsGeometry(TDWay way, List<TDWay> innerWays);  }### Answer:
@Test public void testBuildGeometryFromInValidPolygon() { String testfile = "invalid-polygon.wkt"; String expectedfile = "invalid-polygon-repaired.wkt"; List<TDWay> ways = MockingUtils.wktPolygonToWays(testfile); Geometry geometry = JTSUtils.toJtsGeometry(ways.get(0), ways.subList(1, ways.size())); Assert.isTrue(geometry instanceof Polygon); Assert.isTrue(geometry.isValid()); Geometry expected = MockingUtils.readWKTFile(expectedfile); Assert.equals(expected, geometry); }
@Test public void testBuildGeometryFromInValidPolygonWithHoles() { String testfile = "invalid-polygon-2-inner-rings.wkt"; String expectedfile = "invalid-polygon-2-inner-rings-repaired.wkt"; List<TDWay> ways = MockingUtils.wktPolygonToWays(testfile); Geometry geometry = JTSUtils.toJtsGeometry(ways.get(0), ways.subList(1, ways.size())); Assert.isTrue(geometry instanceof Polygon); Assert.isTrue(geometry.isValid()); Geometry expected = MockingUtils.readWKTFile(expectedfile); Assert.equals(expected, geometry); }
@Test public void testBuildGeometryFromValidPolygon() { String testfile = "valid-polygon.wkt"; List<TDWay> ways = MockingUtils.wktPolygonToWays(testfile); Geometry geometry = JTSUtils.toJtsGeometry(ways.get(0), ways.subList(1, ways.size())); Assert.isTrue(geometry instanceof Polygon); Assert.isTrue(geometry.isValid()); Geometry expected = MockingUtils.readWKTFile(testfile); Assert.equals(expected, geometry); }