@Test public void GIVEN_non_null_solar_radiation_WHEN_formatting_requested_THEN_returns_value_to_one_digit() { testee = new SolarRadiationFormatter(new BigDecimal("0")); assertEquals("0.0 W/m\u00b2", testee.format()); testee = new SolarRadiationFormatter(new BigDecimal("1342.2")); assertEquals("1342.2 W/m\u00b2", testee.format()); }
public String format() { String formatted = "----.- W/m\u00b2"; if (solarRadiation != null) { formatted = String.format(Locale.US, "%1.1f W/m\u00b2", solarRadiation.setScale(1, RoundingMode.HALF_DOWN)); } return formatted; }
SolarRadiationFormatter { public String format() { String formatted = "----.- W/m\u00b2"; if (solarRadiation != null) { formatted = String.format(Locale.US, "%1.1f W/m\u00b2", solarRadiation.setScale(1, RoundingMode.HALF_DOWN)); } return formatted; } }
SolarRadiationFormatter { public String format() { String formatted = "----.- W/m\u00b2"; if (solarRadiation != null) { formatted = String.format(Locale.US, "%1.1f W/m\u00b2", solarRadiation.setScale(1, RoundingMode.HALF_DOWN)); } return formatted; } SolarRadiationFormatter(BigDecimal solarRadiation); }
SolarRadiationFormatter { public String format() { String formatted = "----.- W/m\u00b2"; if (solarRadiation != null) { formatted = String.format(Locale.US, "%1.1f W/m\u00b2", solarRadiation.setScale(1, RoundingMode.HALF_DOWN)); } return formatted; } SolarRadiationFormatter(BigDecimal solarRadiation); String format(); }
SolarRadiationFormatter { public String format() { String formatted = "----.- W/m\u00b2"; if (solarRadiation != null) { formatted = String.format(Locale.US, "%1.1f W/m\u00b2", solarRadiation.setScale(1, RoundingMode.HALF_DOWN)); } return formatted; } SolarRadiationFormatter(BigDecimal solarRadiation); String format();  }