@Test public void testParseTooManyRequestCodeForCurrentWeather() throws JSONException, WeatherException { JSONTokener parser = new JSONTokener("{ \"cod\": 429, \"message\": \"too many requests\"}"); try { OpenWeatherMapWeather weather = new OpenWeatherMapWeather(context); weather.parseCurrentWeather((JSONObject) parser.nextValue()); fail(); } catch (TooManyRequestsException e) { assertEquals("too many requests", e.getMessage()); assertEquals("too many requests", e.getLocalizedMessage()); } }
void parseCurrentWeather(JSONObject json) throws WeatherException { try { checkCode(json); parseCityId(json); parseLocation(json); parseTime(json); WeatherParser parser = new CurrentWeatherParser(json); parser.parseCondition(); } catch (JSONException e) { throw new WeatherException("Failed parsing current weather: " + e.getLocalizedMessage(), e); } this.empty = false; }
OpenWeatherMapWeather implements Weather { void parseCurrentWeather(JSONObject json) throws WeatherException { try { checkCode(json); parseCityId(json); parseLocation(json); parseTime(json); WeatherParser parser = new CurrentWeatherParser(json); parser.parseCondition(); } catch (JSONException e) { throw new WeatherException("Failed parsing current weather: " + e.getLocalizedMessage(), e); } this.empty = false; } }
OpenWeatherMapWeather implements Weather { void parseCurrentWeather(JSONObject json) throws WeatherException { try { checkCode(json); parseCityId(json); parseLocation(json); parseTime(json); WeatherParser parser = new CurrentWeatherParser(json); parser.parseCondition(); } catch (JSONException e) { throw new WeatherException("Failed parsing current weather: " + e.getLocalizedMessage(), e); } this.empty = false; } OpenWeatherMapWeather(Context context);  OpenWeatherMapWeather(Context context, JSONObject jsonObject); }
OpenWeatherMapWeather implements Weather { void parseCurrentWeather(JSONObject json) throws WeatherException { try { checkCode(json); parseCityId(json); parseLocation(json); parseTime(json); WeatherParser parser = new CurrentWeatherParser(json); parser.parseCondition(); } catch (JSONException e) { throw new WeatherException("Failed parsing current weather: " + e.getLocalizedMessage(), e); } this.empty = false; } OpenWeatherMapWeather(Context context);  OpenWeatherMapWeather(Context context, JSONObject jsonObject); @Override Location getLocation(); @Override Date getTime(); @Override Date getQueryTime(); @Override UnitSystem getUnitSystem(); @Override List<WeatherCondition> getConditions(); @Override boolean isEmpty(); int getCityId(); URL getForecastURL(); }
OpenWeatherMapWeather implements Weather { void parseCurrentWeather(JSONObject json) throws WeatherException { try { checkCode(json); parseCityId(json); parseLocation(json); parseTime(json); WeatherParser parser = new CurrentWeatherParser(json); parser.parseCondition(); } catch (JSONException e) { throw new WeatherException("Failed parsing current weather: " + e.getLocalizedMessage(), e); } this.empty = false; } OpenWeatherMapWeather(Context context);  OpenWeatherMapWeather(Context context, JSONObject jsonObject); @Override Location getLocation(); @Override Date getTime(); @Override Date getQueryTime(); @Override UnitSystem getUnitSystem(); @Override List<WeatherCondition> getConditions(); @Override boolean isEmpty(); int getCityId(); URL getForecastURL();  }