@Test
public void generateAdUrl_whenDeveloperSuppliesMoreRecentLocationThanLocationService_shouldUseDeveloperSuppliedLocation() {

    Location locationFromDeveloper = new Location("");
    locationFromDeveloper.setLatitude(42);
    locationFromDeveloper.setLongitude(-42);
    locationFromDeveloper.setAccuracy(3.5f);
    locationFromDeveloper.setTime(1000);
    ShadowLocationManager shadowLocationManager = Robolectric.shadowOf(
            (LocationManager) application.getSystemService(Context.LOCATION_SERVICE));
    // Mock out the LocationManager's last known location to be older than the
    // developer-supplied location.
    Location olderLocation = new Location("");
    olderLocation.setLatitude(40);
    olderLocation.setLongitude(-105);
    olderLocation.setAccuracy(8.0f);
    olderLocation.setTime(500);
    shadowLocationManager.setLastKnownLocation(LocationManager.GPS_PROVIDER, olderLocation);
    String adUrl = subject.withLocation(locationFromDeveloper)
            .generateUrlString("ads.mopub.com");
    assertThat(getParameterFromRequestUrl(adUrl, "ll")).isEqualTo("42.0,-42.0");
    assertThat(getParameterFromRequestUrl(adUrl, "lla")).isEqualTo("3");
    assertThat(getParameterFromRequestUrl(adUrl, "llsdk")).isEmpty();
}