Code example for Geocoder

Methods: getFromLocationName

0
    } 
 
    @Test 
    public void setsUpHasLocationInAddressFromLocationName() throws Exception { 
        shadowOf(geocoder).setSimulatedHasLatLong(true, true);
        Address address = geocoder.getFromLocationName("731 Market St, San Francisco, CA 94103", 1).get(0);
        assertTrue(address.hasLatitude());
        assertTrue(address.hasLongitude());
        shadowOf(geocoder).setSimulatedHasLatLong(false, false);
        address = geocoder.getFromLocationName("731 Market St, San Francisco, CA 94103", 1).get(0);
        assertFalse(address.hasLatitude());
        assertFalse(address.hasLongitude());
    } 
 
    @Test 
    public void canReturnNoAddressesOnRequest() throws Exception { 
        shadowOf(geocoder).setReturnNoResults(true);
        List<Address> result = geocoder.getFromLocationName("731 Market St, San Francisco, CA 94103", 1);
        assertEquals(0, result.size());
    }