DirectionsResponse extends DirectionsJsonObject { public static DirectionsResponse fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); gson.registerTypeAdapter(Point.class, new PointAsCoordinatesTypeAdapter()); return gson.create().fromJson(json, DirectionsResponse.class); }  @NonNull static Builder builder(); @NonNull abstract String code(); @Nullable abstract String message(); @Nullable abstract List<DirectionsWaypoint> waypoints(); @NonNull abstract List<DirectionsRoute> routes(); @Nullable abstract String uuid(); abstract Builder toBuilder(); static TypeAdapter<DirectionsResponse> typeAdapter(Gson gson); static DirectionsResponse fromJson(String json);  }
@Test public void testToFromJson() throws Exception { String json = loadJsonFixture(DIRECTIONS_V5_PRECISION6_FIXTURE); DirectionsResponse responseFromJson1 = DirectionsResponse.fromJson(json); String jsonString = responseFromJson1.toJson(); DirectionsResponse responseFromJson2 = DirectionsResponse.fromJson(jsonString); Assert.assertEquals(responseFromJson1, responseFromJson2); Assert.assertEquals(responseFromJson2, responseFromJson1); }