@Test public void GIVEN_populated_client_raw_fields_WHEN_daily_rainfall_formatting_requested_THEN_formatted_value_returned() { FormattedWeatherItem formattedWeatherItem = testee.format(WeatherItem.DAILY_RAINFALL); assertEquals("daily rain", formattedWeatherItem.getLabel()); assertEquals("5.71 mm", formattedWeatherItem.getValue()); }
public FormattedWeatherItem format(WeatherItem weatherItem) { FormattedWeatherItem formattedWeatherItem = null; switch (weatherItem) { case APPARENT_TEMPERATURE: formattedWeatherItem = new FormattedWeatherItem("apparent", new TemperatureFormatter(clientRaw.getApparentTemperature()).format(temperatureUnit)); break; case AVERAGE_WIND: formattedWeatherItem = new FormattedWeatherItem("wind", new WindSpeedFormatter(clientRaw.getAverageWindSpeed()).format(windSpeedUnit) + " " + new WindDirectionFormatter(clientRaw.getWindDirection()).format(windDirectionUnit)); break; case BLANK: formattedWeatherItem = new FormattedWeatherItem("", ""); break; case DAILY_RAINFALL: formattedWeatherItem = new FormattedWeatherItem("daily rain", new RainfallFormatter(clientRaw.getDailyRainfall()).format(rainfallUnit)); break; case DEW_POINT: formattedWeatherItem = new FormattedWeatherItem("dew point", new TemperatureFormatter(clientRaw.getDewPoint()).format(temperatureUnit)); break; case FORECAST: formattedWeatherItem = new FormattedWeatherItem("fcst", new ConditionsFormatter(clientRaw.getForecast()).format()); break; case GUST: formattedWeatherItem = new FormattedWeatherItem("gust", new WindSpeedFormatter(clientRaw.getGustSpeed()).format(windSpeedUnit)); break; case HEAT_INDEX: formattedWeatherItem = new FormattedWeatherItem("heat index", new TemperatureFormatter(clientRaw.getHeatIndex()).format(temperatureUnit)); break; case HUMIDEX: formattedWeatherItem = new FormattedWeatherItem("humidex", new TemperatureFormatter(clientRaw.getHumidex()).format(temperatureUnit)); break; case HUMIDITY: formattedWeatherItem = new FormattedWeatherItem("humidity", new HumidityFormatter(clientRaw.getOutdoorHumidityPercentage()).format() + " " + new TrendFormatter(clientRaw.getOutdoorHumidityTrend()).format()); break; case INDOOR_CONDITIONS: formattedWeatherItem = new FormattedWeatherItem("indoor", new TemperatureFormatter(clientRaw.getIndoorTemperature()).format(temperatureUnit) + ", " + new HumidityFormatter(clientRaw.getIndoorHumidityPercentage()).format()); break; case RAINFALL_RATE: formattedWeatherItem = new FormattedWeatherItem("rain rate", new RainfallRateFormatter(clientRaw.getRainfallRatePerMinute()).format(rainfallUnit)); break; case SOLAR: formattedWeatherItem = new FormattedWeatherItem("solar", new SolarRadiationFormatter(clientRaw.getSolarRadiation()).format() + ", " + new SolarPercentageFormatter(clientRaw.getSolarPercentage()).format()); break; case SURFACE_PRESSURE: formattedWeatherItem = new FormattedWeatherItem("press", new PressureFormatter(clientRaw.getSurfacePressure()).format(pressureUnit) + " " + new TrendFormatter(clientRaw.getSurfacePressureTrend()).format()); break; case UV_INDEX: formattedWeatherItem = new FormattedWeatherItem("uv index", new UvIndexFormatter(clientRaw.getUvIndex()).format()); break; case WIND_CHILL: formattedWeatherItem = new FormattedWeatherItem("wind chill", new TemperatureFormatter(clientRaw.getWindChill()).format(temperatureUnit)); break; } return formattedWeatherItem; }
WeatherItemFormatter { public FormattedWeatherItem format(WeatherItem weatherItem) { FormattedWeatherItem formattedWeatherItem = null; switch (weatherItem) { case APPARENT_TEMPERATURE: formattedWeatherItem = new FormattedWeatherItem("apparent", new TemperatureFormatter(clientRaw.getApparentTemperature()).format(temperatureUnit)); break; case AVERAGE_WIND: formattedWeatherItem = new FormattedWeatherItem("wind", new WindSpeedFormatter(clientRaw.getAverageWindSpeed()).format(windSpeedUnit) + " " + new WindDirectionFormatter(clientRaw.getWindDirection()).format(windDirectionUnit)); break; case BLANK: formattedWeatherItem = new FormattedWeatherItem("", ""); break; case DAILY_RAINFALL: formattedWeatherItem = new FormattedWeatherItem("daily rain", new RainfallFormatter(clientRaw.getDailyRainfall()).format(rainfallUnit)); break; case DEW_POINT: formattedWeatherItem = new FormattedWeatherItem("dew point", new TemperatureFormatter(clientRaw.getDewPoint()).format(temperatureUnit)); break; case FORECAST: formattedWeatherItem = new FormattedWeatherItem("fcst", new ConditionsFormatter(clientRaw.getForecast()).format()); break; case GUST: formattedWeatherItem = new FormattedWeatherItem("gust", new WindSpeedFormatter(clientRaw.getGustSpeed()).format(windSpeedUnit)); break; case HEAT_INDEX: formattedWeatherItem = new FormattedWeatherItem("heat index", new TemperatureFormatter(clientRaw.getHeatIndex()).format(temperatureUnit)); break; case HUMIDEX: formattedWeatherItem = new FormattedWeatherItem("humidex", new TemperatureFormatter(clientRaw.getHumidex()).format(temperatureUnit)); break; case HUMIDITY: formattedWeatherItem = new FormattedWeatherItem("humidity", new HumidityFormatter(clientRaw.getOutdoorHumidityPercentage()).format() + " " + new TrendFormatter(clientRaw.getOutdoorHumidityTrend()).format()); break; case INDOOR_CONDITIONS: formattedWeatherItem = new FormattedWeatherItem("indoor", new TemperatureFormatter(clientRaw.getIndoorTemperature()).format(temperatureUnit) + ", " + new HumidityFormatter(clientRaw.getIndoorHumidityPercentage()).format()); break; case RAINFALL_RATE: formattedWeatherItem = new FormattedWeatherItem("rain rate", new RainfallRateFormatter(clientRaw.getRainfallRatePerMinute()).format(rainfallUnit)); break; case SOLAR: formattedWeatherItem = new FormattedWeatherItem("solar", new SolarRadiationFormatter(clientRaw.getSolarRadiation()).format() + ", " + new SolarPercentageFormatter(clientRaw.getSolarPercentage()).format()); break; case SURFACE_PRESSURE: formattedWeatherItem = new FormattedWeatherItem("press", new PressureFormatter(clientRaw.getSurfacePressure()).format(pressureUnit) + " " + new TrendFormatter(clientRaw.getSurfacePressureTrend()).format()); break; case UV_INDEX: formattedWeatherItem = new FormattedWeatherItem("uv index", new UvIndexFormatter(clientRaw.getUvIndex()).format()); break; case WIND_CHILL: formattedWeatherItem = new FormattedWeatherItem("wind chill", new TemperatureFormatter(clientRaw.getWindChill()).format(temperatureUnit)); break; } return formattedWeatherItem; } }
WeatherItemFormatter { public FormattedWeatherItem format(WeatherItem weatherItem) { FormattedWeatherItem formattedWeatherItem = null; switch (weatherItem) { case APPARENT_TEMPERATURE: formattedWeatherItem = new FormattedWeatherItem("apparent", new TemperatureFormatter(clientRaw.getApparentTemperature()).format(temperatureUnit)); break; case AVERAGE_WIND: formattedWeatherItem = new FormattedWeatherItem("wind", new WindSpeedFormatter(clientRaw.getAverageWindSpeed()).format(windSpeedUnit) + " " + new WindDirectionFormatter(clientRaw.getWindDirection()).format(windDirectionUnit)); break; case BLANK: formattedWeatherItem = new FormattedWeatherItem("", ""); break; case DAILY_RAINFALL: formattedWeatherItem = new FormattedWeatherItem("daily rain", new RainfallFormatter(clientRaw.getDailyRainfall()).format(rainfallUnit)); break; case DEW_POINT: formattedWeatherItem = new FormattedWeatherItem("dew point", new TemperatureFormatter(clientRaw.getDewPoint()).format(temperatureUnit)); break; case FORECAST: formattedWeatherItem = new FormattedWeatherItem("fcst", new ConditionsFormatter(clientRaw.getForecast()).format()); break; case GUST: formattedWeatherItem = new FormattedWeatherItem("gust", new WindSpeedFormatter(clientRaw.getGustSpeed()).format(windSpeedUnit)); break; case HEAT_INDEX: formattedWeatherItem = new FormattedWeatherItem("heat index", new TemperatureFormatter(clientRaw.getHeatIndex()).format(temperatureUnit)); break; case HUMIDEX: formattedWeatherItem = new FormattedWeatherItem("humidex", new TemperatureFormatter(clientRaw.getHumidex()).format(temperatureUnit)); break; case HUMIDITY: formattedWeatherItem = new FormattedWeatherItem("humidity", new HumidityFormatter(clientRaw.getOutdoorHumidityPercentage()).format() + " " + new TrendFormatter(clientRaw.getOutdoorHumidityTrend()).format()); break; case INDOOR_CONDITIONS: formattedWeatherItem = new FormattedWeatherItem("indoor", new TemperatureFormatter(clientRaw.getIndoorTemperature()).format(temperatureUnit) + ", " + new HumidityFormatter(clientRaw.getIndoorHumidityPercentage()).format()); break; case RAINFALL_RATE: formattedWeatherItem = new FormattedWeatherItem("rain rate", new RainfallRateFormatter(clientRaw.getRainfallRatePerMinute()).format(rainfallUnit)); break; case SOLAR: formattedWeatherItem = new FormattedWeatherItem("solar", new SolarRadiationFormatter(clientRaw.getSolarRadiation()).format() + ", " + new SolarPercentageFormatter(clientRaw.getSolarPercentage()).format()); break; case SURFACE_PRESSURE: formattedWeatherItem = new FormattedWeatherItem("press", new PressureFormatter(clientRaw.getSurfacePressure()).format(pressureUnit) + " " + new TrendFormatter(clientRaw.getSurfacePressureTrend()).format()); break; case UV_INDEX: formattedWeatherItem = new FormattedWeatherItem("uv index", new UvIndexFormatter(clientRaw.getUvIndex()).format()); break; case WIND_CHILL: formattedWeatherItem = new FormattedWeatherItem("wind chill", new TemperatureFormatter(clientRaw.getWindChill()).format(temperatureUnit)); break; } return formattedWeatherItem; } WeatherItemFormatter(ClientRaw clientRaw, TemperatureUnit temperatureUnit, PressureUnit pressureUnit, WindSpeedUnit windSpeedUnit, WindDirectionUnit windDirectionUnit, RainfallUnit rainfallUnit); }
WeatherItemFormatter { public FormattedWeatherItem format(WeatherItem weatherItem) { FormattedWeatherItem formattedWeatherItem = null; switch (weatherItem) { case APPARENT_TEMPERATURE: formattedWeatherItem = new FormattedWeatherItem("apparent", new TemperatureFormatter(clientRaw.getApparentTemperature()).format(temperatureUnit)); break; case AVERAGE_WIND: formattedWeatherItem = new FormattedWeatherItem("wind", new WindSpeedFormatter(clientRaw.getAverageWindSpeed()).format(windSpeedUnit) + " " + new WindDirectionFormatter(clientRaw.getWindDirection()).format(windDirectionUnit)); break; case BLANK: formattedWeatherItem = new FormattedWeatherItem("", ""); break; case DAILY_RAINFALL: formattedWeatherItem = new FormattedWeatherItem("daily rain", new RainfallFormatter(clientRaw.getDailyRainfall()).format(rainfallUnit)); break; case DEW_POINT: formattedWeatherItem = new FormattedWeatherItem("dew point", new TemperatureFormatter(clientRaw.getDewPoint()).format(temperatureUnit)); break; case FORECAST: formattedWeatherItem = new FormattedWeatherItem("fcst", new ConditionsFormatter(clientRaw.getForecast()).format()); break; case GUST: formattedWeatherItem = new FormattedWeatherItem("gust", new WindSpeedFormatter(clientRaw.getGustSpeed()).format(windSpeedUnit)); break; case HEAT_INDEX: formattedWeatherItem = new FormattedWeatherItem("heat index", new TemperatureFormatter(clientRaw.getHeatIndex()).format(temperatureUnit)); break; case HUMIDEX: formattedWeatherItem = new FormattedWeatherItem("humidex", new TemperatureFormatter(clientRaw.getHumidex()).format(temperatureUnit)); break; case HUMIDITY: formattedWeatherItem = new FormattedWeatherItem("humidity", new HumidityFormatter(clientRaw.getOutdoorHumidityPercentage()).format() + " " + new TrendFormatter(clientRaw.getOutdoorHumidityTrend()).format()); break; case INDOOR_CONDITIONS: formattedWeatherItem = new FormattedWeatherItem("indoor", new TemperatureFormatter(clientRaw.getIndoorTemperature()).format(temperatureUnit) + ", " + new HumidityFormatter(clientRaw.getIndoorHumidityPercentage()).format()); break; case RAINFALL_RATE: formattedWeatherItem = new FormattedWeatherItem("rain rate", new RainfallRateFormatter(clientRaw.getRainfallRatePerMinute()).format(rainfallUnit)); break; case SOLAR: formattedWeatherItem = new FormattedWeatherItem("solar", new SolarRadiationFormatter(clientRaw.getSolarRadiation()).format() + ", " + new SolarPercentageFormatter(clientRaw.getSolarPercentage()).format()); break; case SURFACE_PRESSURE: formattedWeatherItem = new FormattedWeatherItem("press", new PressureFormatter(clientRaw.getSurfacePressure()).format(pressureUnit) + " " + new TrendFormatter(clientRaw.getSurfacePressureTrend()).format()); break; case UV_INDEX: formattedWeatherItem = new FormattedWeatherItem("uv index", new UvIndexFormatter(clientRaw.getUvIndex()).format()); break; case WIND_CHILL: formattedWeatherItem = new FormattedWeatherItem("wind chill", new TemperatureFormatter(clientRaw.getWindChill()).format(temperatureUnit)); break; } return formattedWeatherItem; } WeatherItemFormatter(ClientRaw clientRaw, TemperatureUnit temperatureUnit, PressureUnit pressureUnit, WindSpeedUnit windSpeedUnit, WindDirectionUnit windDirectionUnit, RainfallUnit rainfallUnit); FormattedWeatherItem format(WeatherItem weatherItem); }
WeatherItemFormatter { public FormattedWeatherItem format(WeatherItem weatherItem) { FormattedWeatherItem formattedWeatherItem = null; switch (weatherItem) { case APPARENT_TEMPERATURE: formattedWeatherItem = new FormattedWeatherItem("apparent", new TemperatureFormatter(clientRaw.getApparentTemperature()).format(temperatureUnit)); break; case AVERAGE_WIND: formattedWeatherItem = new FormattedWeatherItem("wind", new WindSpeedFormatter(clientRaw.getAverageWindSpeed()).format(windSpeedUnit) + " " + new WindDirectionFormatter(clientRaw.getWindDirection()).format(windDirectionUnit)); break; case BLANK: formattedWeatherItem = new FormattedWeatherItem("", ""); break; case DAILY_RAINFALL: formattedWeatherItem = new FormattedWeatherItem("daily rain", new RainfallFormatter(clientRaw.getDailyRainfall()).format(rainfallUnit)); break; case DEW_POINT: formattedWeatherItem = new FormattedWeatherItem("dew point", new TemperatureFormatter(clientRaw.getDewPoint()).format(temperatureUnit)); break; case FORECAST: formattedWeatherItem = new FormattedWeatherItem("fcst", new ConditionsFormatter(clientRaw.getForecast()).format()); break; case GUST: formattedWeatherItem = new FormattedWeatherItem("gust", new WindSpeedFormatter(clientRaw.getGustSpeed()).format(windSpeedUnit)); break; case HEAT_INDEX: formattedWeatherItem = new FormattedWeatherItem("heat index", new TemperatureFormatter(clientRaw.getHeatIndex()).format(temperatureUnit)); break; case HUMIDEX: formattedWeatherItem = new FormattedWeatherItem("humidex", new TemperatureFormatter(clientRaw.getHumidex()).format(temperatureUnit)); break; case HUMIDITY: formattedWeatherItem = new FormattedWeatherItem("humidity", new HumidityFormatter(clientRaw.getOutdoorHumidityPercentage()).format() + " " + new TrendFormatter(clientRaw.getOutdoorHumidityTrend()).format()); break; case INDOOR_CONDITIONS: formattedWeatherItem = new FormattedWeatherItem("indoor", new TemperatureFormatter(clientRaw.getIndoorTemperature()).format(temperatureUnit) + ", " + new HumidityFormatter(clientRaw.getIndoorHumidityPercentage()).format()); break; case RAINFALL_RATE: formattedWeatherItem = new FormattedWeatherItem("rain rate", new RainfallRateFormatter(clientRaw.getRainfallRatePerMinute()).format(rainfallUnit)); break; case SOLAR: formattedWeatherItem = new FormattedWeatherItem("solar", new SolarRadiationFormatter(clientRaw.getSolarRadiation()).format() + ", " + new SolarPercentageFormatter(clientRaw.getSolarPercentage()).format()); break; case SURFACE_PRESSURE: formattedWeatherItem = new FormattedWeatherItem("press", new PressureFormatter(clientRaw.getSurfacePressure()).format(pressureUnit) + " " + new TrendFormatter(clientRaw.getSurfacePressureTrend()).format()); break; case UV_INDEX: formattedWeatherItem = new FormattedWeatherItem("uv index", new UvIndexFormatter(clientRaw.getUvIndex()).format()); break; case WIND_CHILL: formattedWeatherItem = new FormattedWeatherItem("wind chill", new TemperatureFormatter(clientRaw.getWindChill()).format(temperatureUnit)); break; } return formattedWeatherItem; } WeatherItemFormatter(ClientRaw clientRaw, TemperatureUnit temperatureUnit, PressureUnit pressureUnit, WindSpeedUnit windSpeedUnit, WindDirectionUnit windDirectionUnit, RainfallUnit rainfallUnit); FormattedWeatherItem format(WeatherItem weatherItem);  }