### Question:
Polygon extends Message { public static Polygon fromJsonObject(JsonObject jsonObject) { JsonArray jsonPoints = jsonObject.getJsonArray(Polygon.FIELD_POINTS); if (jsonPoints != null) { Point32[] points = new Point32[jsonPoints.size()]; for (int i = 0; i < points.length; i++) { points[i] = Point32.fromJsonObject(jsonPoints.getJsonObject(i)); } return new Polygon(points); } else { return new Polygon(); } } Polygon();  Polygon(Point32[] points); int size(); Point32 get(int index); Point32[] getPoints(); @Override Polygon clone(); static Polygon fromJsonString(String jsonString); static Polygon fromMessage(Message m); static Polygon fromJsonObject(JsonObject jsonObject); static final String FIELD_POINTS; static final String TYPE; }### Answer:
@Test public void testFromJsonObject() { JsonArrayBuilder array = Json.createArrayBuilder(); for (Point32 p : p1.getPoints()) { array.add(p.toJsonObject()); } JsonObject jsonObject = Json.createObjectBuilder() .add(Polygon.FIELD_POINTS, array.build()).build(); Polygon p = Polygon.fromJsonObject(jsonObject); assertEquals(p1.toString(), p.toString()); assertEquals(p1.toJsonObject(), p.toJsonObject()); assertEquals(p1.getMessageType(), p.getMessageType()); assertTrue(Arrays.deepEquals(p1.getPoints(), p.getPoints())); assertNotSame(p1, p); assertNotSame(p1.toString(), p.toString()); assertNotSame(p1.toJsonObject(), p.toJsonObject()); assertEquals(p1.size(), p.size()); }