### Question:
NavigationFasterRouteListener implements RouteListener { @Override public void onResponseReceived(DirectionsResponse response, @Nullable RouteProgress routeProgress) { if (fasterRouteEngine.isFasterRoute(response, routeProgress)) { eventDispatcher.onFasterRouteEvent(response.routes().get(FIRST_ROUTE)); } } NavigationFasterRouteListener(NavigationEventDispatcher eventDispatcher, FasterRoute fasterRouteEngine); @Override void onResponseReceived(DirectionsResponse response, @Nullable RouteProgress routeProgress); @Override void onErrorReceived(Throwable throwable);  }### Answer:
@Test public void onResponseReceived_fasterRouteIsSentToDispatcher() { NavigationEventDispatcher eventDispatcher = mock(NavigationEventDispatcher.class); FasterRoute fasterRoute = buildFasterRouteThatReturns(true); NavigationFasterRouteListener listener = new NavigationFasterRouteListener(eventDispatcher, fasterRoute); DirectionsResponse response = buildDirectionsResponse(); RouteProgress routeProgress = mock(RouteProgress.class); listener.onResponseReceived(response, routeProgress); verify(eventDispatcher).onFasterRouteEvent(any(DirectionsRoute.class)); }
@Test public void onResponseReceived_slowerRouteIsNotSentToDispatcher() { NavigationEventDispatcher eventDispatcher = mock(NavigationEventDispatcher.class); FasterRoute fasterRoute = buildFasterRouteThatReturns(false); NavigationFasterRouteListener listener = new NavigationFasterRouteListener(eventDispatcher, fasterRoute); DirectionsResponse response = buildDirectionsResponse(); RouteProgress routeProgress = mock(RouteProgress.class); listener.onResponseReceived(response, routeProgress); verifyZeroInteractions(eventDispatcher); }