### Question:
HostGeoInfo implements Serializable { public static HostGeoInfo fromLocation(Location l) { if (l==null) return null; Location la = l; HostGeoInfo resultFromLocation = null; while (la!=null) { if (la instanceof HasHostGeoInfo) { resultFromLocation = ((HasHostGeoInfo)l).getHostGeoInfo(); if (resultFromLocation!=null) break; } la = la.getParent(); } if (resultFromLocation!=null && l==la) { return resultFromLocation; } InetAddress address = findIpAddress(l); Object latitude = l.getConfig(LocationConfigKeys.LATITUDE); Object longitude = l.getConfig(LocationConfigKeys.LONGITUDE); if (resultFromLocation!=null && (latitude == null || longitude == null)) { latitude = resultFromLocation.latitude; longitude = resultFromLocation.longitude; } if (address!=null && (latitude == null || longitude == null)) { HostGeoInfo geo = fromIpAddress(address); if (geo==null) return null; latitude = geo.latitude; longitude = geo.longitude; } if (latitude==null || longitude==null) return null; Exception error=null; try { latitude = TypeCoercions.castPrimitive(latitude, Double.class); longitude = TypeCoercions.castPrimitive(longitude, Double.class); } catch (Exception e) { Exceptions.propagateIfFatal(e); error = e; } if (error!=null || !(latitude instanceof Double) || !(longitude instanceof Double)) throw new IllegalArgumentException("Location "+l+" specifies invalid type of lat/long: " + "lat="+latitude+" (type "+(latitude==null ? null : latitude.getClass())+"); " + "lon="+longitude+" (type "+(longitude==null ? null : longitude.getClass())+")", error); HostGeoInfo result = new HostGeoInfo(address!=null ? address.getHostAddress() : null, l.getDisplayName(), (Double) latitude, (Double) longitude); if (l instanceof AbstractLocation) { ((AbstractLocation)l).setHostGeoInfo(result); } return result; } HostGeoInfo(String address, String displayName, double latitude, double longitude); static HostGeoInfo create(String address, String displayName, double latitude, double longitude); static HostGeoInfo fromIpAddress(InetAddress address); @Nullable static HostGeoLookup getDefaultLookup(); static void clearCachedLookup(); static HostGeoInfo fromLocation(Location l); static HostGeoInfo fromEntity(Entity e); static InetAddress findIpAddress(Location l); String getAddress(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final Logger log; final String address; final String displayName; final double latitude; final double longitude; }### Answer:
@Test public void testCustomLocationCoordinates() { HostGeoInfo hgi = HostGeoInfo.fromLocation(CUSTOM_LOCATION); assertNotNull(hgi); assertEquals(50.0d, hgi.latitude); assertEquals(0.0d, hgi.longitude); }
@Test public void testCustomLocationChildCoordinates() { HostGeoInfo hgi = HostGeoInfo.fromLocation(CUSTOM_LOCATION_CHILD); assertNotNull(hgi); assertEquals(50.0d, hgi.latitude); assertEquals(0.0d, hgi.longitude); }