### Question:
NavigationLocationEngineListener implements LocationEngineListener { @Override public void onLocationChanged(Location location) { if (isValidLocationUpdate(location)) { queueLocationUpdate(location); } } NavigationLocationEngineListener(RouteProcessorBackgroundThread thread, MapboxNavigation mapboxNavigation,
                                   LocationEngine locationEngine, LocationValidator validator); @Override @SuppressWarnings("MissingPermission") void onConnected(); @Override void onLocationChanged(Location location);  }### Answer:
@Test public void queueValidLocationUpdate_threadReceivesUpdate() { RouteProcessorBackgroundThread thread = mock(RouteProcessorBackgroundThread.class); LocationValidator validator = mock(LocationValidator.class); when(validator.isValidUpdate(any(Location.class))).thenReturn(true); NavigationLocationEngineListener listener = buildListener(thread, validator); listener.onLocationChanged(mock(Location.class)); verify(thread).queueUpdate(any(NavigationLocationUpdate.class)); }
@Test public void queueInvalidLocationUpdate_threadDoesNotReceiveUpdate() { RouteProcessorBackgroundThread thread = mock(RouteProcessorBackgroundThread.class); LocationValidator validator = mock(LocationValidator.class); when(validator.isValidUpdate(any(Location.class))).thenReturn(false); NavigationLocationEngineListener listener = buildListener(thread, validator); listener.onLocationChanged(mock(Location.class)); verifyZeroInteractions(thread); }