MapboxStreetsV8 extends DirectionsJsonObject { public static MapboxStreetsV8 fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, MapboxStreetsV8.class); }  @Nullable @SerializedName("class") abstract String roadClass(); static Builder builder(); abstract Builder toBuilder(); static TypeAdapter<MapboxStreetsV8> typeAdapter(Gson gson); static MapboxStreetsV8 fromJson(String json);  }
@Test public void testFromJson() { String streetJsonString = "{" + "\"class\": \"street\"" + "}"; MapboxStreetsV8 street = MapboxStreetsV8.fromJson(streetJsonString); Assert.assertEquals("street", street.roadClass()); String jsonStr = street.toJson(); compareJson(streetJsonString, jsonStr); }
@Test public void testToFromJson() { MapboxStreetsV8 street = buildDefaultStreet(); String jsonString = street.toJson(); MapboxStreetsV8 streetFromJson = MapboxStreetsV8.fromJson(jsonString); Assert.assertEquals(street, streetFromJson); }