PositiveOrZeroNumber { public static PositiveOrZeroNumber parse(String positiveNumber) throws InvalidPositiveOrZeroNumberException { int numericValue; try { numericValue = Integer.parseInt(positiveNumber); } catch (NumberFormatException e) { throw new InvalidPositiveOrZeroNumberException(); } return new PositiveOrZeroNumber(numericValue); } PositiveOrZeroNumber(int value); static PositiveOrZeroNumber parse(String positiveNumber); int getValue(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void throw_invalid_positiveNumber_exception_if_positiveNumber_is_empty_string() throws InvalidPositiveOrZeroNumberException { thrown.expect(InvalidPositiveOrZeroNumberException.class); PositiveOrZeroNumber positiveOrZeroNumber = PositiveOrZeroNumber.parse(""); }
@Test public void throw_invalid_positiveNumber_exception_if_positiveNumber_is_text() throws InvalidPositiveOrZeroNumberException { thrown.expect(InvalidPositiveOrZeroNumberException.class); PositiveOrZeroNumber positiveOrZeroNumber = PositiveOrZeroNumber.parse("any text"); }
@Test public void return_positiveNumber_if_parse_with_string_input_between_0_and_99() throws InvalidPositiveOrZeroNumberException { PositiveOrZeroNumber positiveOrZeroNumber = PositiveOrZeroNumber.parse("99"); assertThat(positiveOrZeroNumber, notNullValue()); }