MetOfficeRecordParser { public void parse(String record) { if (record.length() < 18) { return; } year = record.substring(3, 7); if (isValidRecord(year)) { airTemperatureString = record.substring(13, 18); if (!airTemperatureString.trim().equals("---")) { BigDecimal temp = new BigDecimal(airTemperatureString.trim()); temp = temp.multiply(new BigDecimal(BigInteger.TEN)); airTemperature = temp.intValueExact(); airTemperatureValid = true; } } }  void parse(String record); void parse(Text record); String getYear(); int getAirTemperature(); String getAirTemperatureString(); boolean isValidTemperature();  }
@Test(expected=NumberFormatException.class) public void cannotParseMalformedTemperature() { parser.parse(" 1978 1 X.5 2.0 6 134.1 64.7"); }