@Test public void shouldThrowErrorIfValueIsNegative() throws Exception { Reading reading = new Reading("-345", false); expectedException.expect(DataException.class); expectedException.expectMessage("error.epi.use.line.item.invalid"); reading.parsePositiveInt(); }
public Integer parsePositiveInt() { String stringValue = getEffectiveValue(); if (stringValue == null) { return null; } int intValue = Integer.parseInt(stringValue); if (intValue < 0) { throw new DataException("error.epi.use.line.item.invalid"); } return intValue; }
Reading { public Integer parsePositiveInt() { String stringValue = getEffectiveValue(); if (stringValue == null) { return null; } int intValue = Integer.parseInt(stringValue); if (intValue < 0) { throw new DataException("error.epi.use.line.item.invalid"); } return intValue; } }
Reading { public Integer parsePositiveInt() { String stringValue = getEffectiveValue(); if (stringValue == null) { return null; } int intValue = Integer.parseInt(stringValue); if (intValue < 0) { throw new DataException("error.epi.use.line.item.invalid"); } return intValue; } Reading(String value, Boolean notRecorded); }
Reading { public Integer parsePositiveInt() { String stringValue = getEffectiveValue(); if (stringValue == null) { return null; } int intValue = Integer.parseInt(stringValue); if (intValue < 0) { throw new DataException("error.epi.use.line.item.invalid"); } return intValue; } Reading(String value, Boolean notRecorded); String getEffectiveValue(); Integer parsePositiveInt(); Integer parseInt(); Float parseFloat(); }
Reading { public Integer parsePositiveInt() { String stringValue = getEffectiveValue(); if (stringValue == null) { return null; } int intValue = Integer.parseInt(stringValue); if (intValue < 0) { throw new DataException("error.epi.use.line.item.invalid"); } return intValue; } Reading(String value, Boolean notRecorded); String getEffectiveValue(); Integer parsePositiveInt(); Integer parseInt(); Float parseFloat();  }