@Test
  public void testDurationInTrafficWithTrafficModel() throws Exception {
    try (LocalTestServerContext sc = new LocalTestServerContext("{\"status\" : \"OK\"}")) {
      final long ONE_HOUR_MILLIS = 60 * 60 * 1000;
      DistanceMatrixApi.newRequest(sc.context)
          .origins("Fisherman's Wharf, San Francisco")
          .destinations("San Francisco International Airport, San Francisco, CA")
          .mode(TravelMode.DRIVING)
          .trafficModel(TrafficModel.PESSIMISTIC)
          .departureTime(Instant.ofEpochMilli(System.currentTimeMillis() + ONE_HOUR_MILLIS))
          .await();

      sc.assertParamValue("Fisherman's Wharf, San Francisco", "origins");
      sc.assertParamValue("San Francisco International Airport, San Francisco, CA", "destinations");
      sc.assertParamValue(TravelMode.DRIVING.toUrlValue(), "mode");
      sc.assertParamValue(TrafficModel.PESSIMISTIC.toUrlValue(), "traffic_model");
    }
  }
Test duration in traffic with traffic model set.
src/test/java/com/google/maps/DistanceMatrixApiTest.java