PositiveNumber { public static PositiveNumber parse(String positiveNumber) throws InvalidPositiveNumberException { int numericValue; try { numericValue = Integer.parseInt(positiveNumber); } catch (NumberFormatException e) { throw new InvalidPositiveNumberException(); } return new PositiveNumber(numericValue); } PositiveNumber(int value); static PositiveNumber 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 InvalidPositiveNumberException { thrown.expect(InvalidPositiveNumberException.class); PositiveNumber positiveNumber = PositiveNumber.parse(""); }
@Test public void throw_invalid_positiveNumber_exception_if_positiveNumber_is_text() throws InvalidPositiveNumberException { thrown.expect(InvalidPositiveNumberException.class); PositiveNumber positiveNumber = PositiveNumber.parse("any text"); }
@Test public void return_positiveNumber_if_parse_with_string_input_between_1_and_99() throws InvalidPhoneException, InvalidPositiveNumberException { PositiveNumber positiveNumber = PositiveNumber.parse("99"); assertThat(positiveNumber, notNullValue()); }