@Test
  public void testTransitParams() throws Exception {
    try (LocalTestServerContext sc =
        new LocalTestServerContext("{\"routes\": [{}],\"status\": \"OK\"}")) {
      DirectionsResult result =
          DirectionsApi.newRequest(sc.context)
              .origin("Fisherman's Wharf, San Francisco")
              .destination("Union Square, San Francisco")
              .mode(TravelMode.TRANSIT)
              .transitMode(TransitMode.BUS, TransitMode.TRAM)
              .transitRoutingPreference(TransitRoutingPreference.LESS_WALKING)
              .await();

      sc.assertParamValue("Fisherman's Wharf, San Francisco", "origin");
      sc.assertParamValue("Union Square, San Francisco", "destination");
      sc.assertParamValue(TravelMode.TRANSIT.toUrlValue(), "mode");
      sc.assertParamValue(
          TransitMode.BUS.toUrlValue() + "|" + TransitMode.TRAM.toUrlValue(), "transit_mode");
      sc.assertParamValue(
          TransitRoutingPreference.LESS_WALKING.toUrlValue(), "transit_routing_preference");

      assertNotNull(result.toString());
    }
  }
Test the extended transit parameters: mode and routing preference.
src/test/java/com/google/maps/DirectionsApiTest.java