StepManeuver extends DirectionsJsonObject { public static StepManeuver fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, StepManeuver.class); }  static Builder builder(); @NonNull Point location(); @Nullable @SerializedName("bearing_before") abstract Double bearingBefore(); @Nullable @SerializedName("bearing_after") abstract Double bearingAfter(); @Nullable abstract String instruction(); @Nullable @StepManeuverType abstract String type(); @Nullable abstract String modifier(); @Nullable abstract Integer exit(); abstract Builder toBuilder(); static TypeAdapter<StepManeuver> typeAdapter(Gson gson); static StepManeuver fromJson(String json); static final String TURN; static final String NEW_NAME; static final String DEPART; static final String ARRIVE; static final String MERGE; static final String ON_RAMP; static final String OFF_RAMP; static final String FORK; static final String END_OF_ROAD; static final String CONTINUE; static final String ROUNDABOUT; static final String ROTARY; static final String ROUNDABOUT_TURN; static final String NOTIFICATION; static final String EXIT_ROUNDABOUT; static final String EXIT_ROTARY; }
@Test public void testFromJson() { String stepManeuverJsonString = "{\"bearing_before\": 299," + "\"bearing_after\": 202, " + "\"type\": \"turn\", " + "\"modifier\": \"left\", " + "\"location\": [ 13.424671,52.508812]," + "\"instruction\": \"Turn left onto Adalbertstraße\"}"; StepManeuver stepManeuver = StepManeuver.fromJson(stepManeuverJsonString); Point location = stepManeuver.location(); Assert.assertEquals(13.424671, location.longitude(), 0.0001); Assert.assertEquals(52.508812, location.latitude(), 0.0001); String jsonStr = stepManeuver.toJson(); compareJson(stepManeuverJsonString, jsonStr); }