### Question:
GeomBuilder { public GeomBuilder polygon() { if (gstack.isEmpty() || !(gstack.peek() instanceof LinearRing)) { ring(); } LinearRing[] rings = gpopAll(LinearRing.class); LinearRing outer = rings[0]; LinearRing[] inner = null; if (rings.length > 1) { inner = Arrays.copyOfRange(rings, 1, rings.length); } gstack.push(factory.createPolygon(outer, inner)); return this; } GeomBuilder();  GeomBuilder(GeometryFactory factory);  GeomBuilder(int srid); GeomBuilder point(double x, double y); GeomBuilder pointz(double x, double y, double z); GeomBuilder points(double ...ord); GeomBuilder pointsz(double ...ord); GeomBuilder point(); GeomBuilder lineString(); GeomBuilder ring(); GeomBuilder polygon(); GeomBuilder multiPoint(); GeomBuilder multiLineString(); GeomBuilder multiPolygon(); GeomBuilder collection(); GeomBuilder buffer(double amt); Geometry get(); Point toPoint(); LineString toLineString(); LinearRing toLinearRing(); Polygon toPolygon(); MultiPoint toMultiPoint(); MultiLineString toMultiLineString(); MultiPolygon toMultiPolygon(); GeometryCollection toCollection();  }### Answer:
@Test public void testPolygon() { Polygon p = gb.points(1,2,3,4,5,6,1,2).ring().toPolygon(); LineString outer = p.getExteriorRing(); assertEquals(4, outer.getNumPoints()); assertPoint(outer.getPointN(0), 1,2); assertPoint(outer.getPointN(1), 3,4); assertPoint(outer.getPointN(2), 5,6); assertPoint(outer.getPointN(3), 1,2); }