### Question:
TwistWithCovariance extends Message { public static TwistWithCovariance fromJsonObject(JsonObject jsonObject) { Twist twist = jsonObject.containsKey(TwistWithCovariance.FIELD_TWIST) ? Twist .fromJsonObject(jsonObject .getJsonObject(TwistWithCovariance.FIELD_TWIST)) : new Twist(); JsonArray jsonArray = jsonObject .getJsonArray(TwistWithCovariance.FIELD_COVARIANCE); if (jsonArray != null) { double[] twists = new double[jsonArray.size()]; for (int i = 0; i < twists.length; i++) { twists[i] = jsonArray.getJsonNumber(i).doubleValue(); } return new TwistWithCovariance(twist, twists); } else { return new TwistWithCovariance(twist, new double[TwistWithCovariance.COVARIANCE_SIZE]); } } TwistWithCovariance();  TwistWithCovariance(Twist twist);  TwistWithCovariance(Twist twist, double[] covariance); Twist getTwist(); double[] getCovariance(); double[][] getCovarianceMatrix(); @Override TwistWithCovariance clone(); static TwistWithCovariance fromJsonString(String jsonString); static TwistWithCovariance fromMessage(Message m); static TwistWithCovariance fromJsonObject(JsonObject jsonObject); static final String FIELD_TWIST; static final String FIELD_COVARIANCE; static final String TYPE; static final int COVARIANCE_ROWS; static final int COVARIANCE_COLUMNS; static final int COVARIANCE_SIZE; }### Answer:
@Test public void testFromJsonObject() { JsonArrayBuilder array = Json.createArrayBuilder(); for (Double d : p2.getCovariance()) { array.add(d); } JsonObject jsonObject = Json .createObjectBuilder() .add(TwistWithCovariance.FIELD_TWIST, p2.getTwist().toJsonObject()) .add(TwistWithCovariance.FIELD_COVARIANCE, array.build()) .build(); TwistWithCovariance p = TwistWithCovariance.fromJsonObject(jsonObject); assertEquals(p2.toString(), p.toString()); assertEquals(p2.toJsonObject(), p.toJsonObject()); assertEquals(p2.getMessageType(), p.getMessageType()); assertEquals(p2.getTwist(), p.getTwist()); assertTrue(Arrays.equals(p2.getCovariance(), p.getCovariance())); assertTrue(Arrays.deepEquals(p2.getCovarianceMatrix(), p.getCovarianceMatrix())); assertNotSame(p2, p); assertNotSame(p2.toString(), p.toString()); assertNotSame(p2.toJsonObject(), p.toJsonObject()); assertNotSame(p2.getTwist(), p.getTwist()); assertNotSame(p2.getCovariance(), p.getCovariance()); assertNotSame(p2.getCovarianceMatrix(), p.getCovarianceMatrix()); }