### Question:
PoseWithCovariance extends Message { public static PoseWithCovariance fromJsonObject(JsonObject jsonObject) { Pose pose = jsonObject.containsKey(PoseWithCovariance.FIELD_POSE) ? Pose .fromJsonObject(jsonObject .getJsonObject(PoseWithCovariance.FIELD_POSE)) : new Pose(); JsonArray jsonArray = jsonObject .getJsonArray(PoseWithCovariance.FIELD_COVARIANCE); if (jsonArray != null) { double[] poses = new double[jsonArray.size()]; for (int i = 0; i < poses.length; i++) { poses[i] = jsonArray.getJsonNumber(i).doubleValue(); } return new PoseWithCovariance(pose, poses); } else { return new PoseWithCovariance(pose, new double[PoseWithCovariance.COVARIANCE_SIZE]); } } PoseWithCovariance();  PoseWithCovariance(Pose pose);  PoseWithCovariance(Pose pose, double[] covariance); Pose getPose(); double[] getCovariance(); double[][] getCovarianceMatrix(); @Override PoseWithCovariance clone(); static PoseWithCovariance fromJsonString(String jsonString); static PoseWithCovariance fromMessage(Message m); static PoseWithCovariance fromJsonObject(JsonObject jsonObject); static final String FIELD_POSE; 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(PoseWithCovariance.FIELD_POSE, p2.getPose().toJsonObject()) .add(PoseWithCovariance.FIELD_COVARIANCE, array.build()) .build(); PoseWithCovariance p = PoseWithCovariance.fromJsonObject(jsonObject); assertEquals(p2.toString(), p.toString()); assertEquals(p2.toJsonObject(), p.toJsonObject()); assertEquals(p2.getMessageType(), p.getMessageType()); assertEquals(p2.getPose(), p.getPose()); 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.getPose(), p.getPose()); assertNotSame(p2.getCovariance(), p.getCovariance()); assertNotSame(p2.getCovarianceMatrix(), p.getCovarianceMatrix()); }