### Question:
OpenWeatherMapSource extends HttpWeatherSource implements WeatherSource { @Override public Weather query(Location location) throws WeatherException { if (location == null) { throw new WeatherException("null location"); } if (!location.isGeo()) { try { if (location.getText().startsWith("-")) { return new TestWeather(Integer.parseInt(location.getText())); } if (location.getText().startsWith("+")) { return new TestWeather(Integer.parseInt(location.getText().substring(1))); } } catch (NumberFormatException nfe) { } } OpenWeatherMapWeather weather = new OpenWeatherMapWeather(this.context); weather.parseCurrentWeather(queryCurrentWeather(location)); if (weather.isEmpty()) { return weather; } if (weather.getLocation().isGeo()) { weather.parseOneCallResult(queryOneCallForecast(weather.getLocation())); } return weather; } OpenWeatherMapSource(Context context); @Override Weather query(Location location); @Override Weather query(Location location, Locale locale);  }### Answer:
@Test public void testQueryOmsk() throws WeatherException { WeatherSource source = new OpenWeatherMapSource(context); Location location = new SimpleLocation("lat=54.96&lon=73.38", true); Weather weather = source.query(location); assertNotNull(weather); assertFalse(weather.isEmpty()); }
@Test public void testQueryOmskName() throws WeatherException { WeatherSource source = new OpenWeatherMapSource(context); Location location = new SimpleLocation("q=omsk", false); Weather weather = source.query(location); assertNotNull(weather); assertFalse(weather.isEmpty()); }
@Test public void testQueryOmskForecasts() throws WeatherException { WeatherSource source = new OpenWeatherMapSource(context); Location location = new SimpleLocation("lat=54.96&lon=73.38", true); Weather weather = source.query(location); assertNotNull(weather); assertFalse(weather.isEmpty()); assertEquals(8, weather.getConditions().size()); }
@Test public void testQueryTestLocationPlus() throws WeatherException { WeatherSource source = new OpenWeatherMapSource(context); Location location = new SimpleLocation("+25", false); Weather weather = source.query(location); assertNotNull(weather); assertFalse(weather.isEmpty()); assertEquals("Test location", weather.getLocation().getText()); assertEquals(25, weather.getConditions().get(0).getTemperature(TemperatureUnit.C).getCurrent()); }
@Test public void testQueryTestLocationMinus() throws WeatherException { WeatherSource source = new OpenWeatherMapSource(context); Location location = new SimpleLocation("-25", false); Weather weather = source.query(location); assertNotNull(weather); assertFalse(weather.isEmpty()); assertEquals("Test location", weather.getLocation().getText()); assertEquals(-25, weather.getConditions().get(0).getTemperature(TemperatureUnit.C).getCurrent()); }
@Test public void testQueryLocationWithPositiveGeoCoordinates() throws WeatherException { WeatherSource source = new OpenWeatherMapSource(context); Location location = new NameOpenWeatherMapLocation("55.0,73.4"); Weather weather = source.query(location); assertNotNull(weather); assertTrue(weather instanceof OpenWeatherMapWeather); assertFalse(weather.isEmpty()); assertEquals("Omsk", weather.getLocation().getText()); assertEquals(8, weather.getConditions().size()); }
@Test public void testQueryLocationWithNegativeGeoCoordinates() throws WeatherException { WeatherSource source = new OpenWeatherMapSource(context); Location location = new NameOpenWeatherMapLocation("-34.8,-56.3"); Weather weather = source.query(location); assertNotNull(weather); assertTrue(weather instanceof OpenWeatherMapWeather); assertFalse(weather.isEmpty()); assertEquals("Pajas Blancas", weather.getLocation().getText()); assertEquals(8, weather.getConditions().size()); }