MigrationProperties extends Properties { public int getRequiredInt(String property) { String prop = getRequiredString(property); try { return Integer.parseInt(prop); } catch (NumberFormatException e) { throw new IllegalArgumentException("Property " + property + " expected type: int"); } } MigrationProperties(String filePath); String getStringOrNull(String property); String getRequiredString(String property); int getRequiredInt(String property); long getRequiredLong(String property); boolean getBoolean(String property, boolean defaultValue);  }
@Test public void testGetRequiredIntValid() { assertEquals(VALID_INT_VALUE, sut.getRequiredInt(VALID_INT)); }
@Test public void testGetRequiredIntNeedsTrimmed() { assertEquals(VALID_INT_VALUE, sut.getRequiredInt(NEEDS_TRIMMED_INT)); }
@Test public void testGetRequiredIntMissing() { exception.expect(IllegalArgumentException.class); sut.getRequiredInt(MISSING_PROPERTY); }
@Test public void testGetRequiredIntEmpty() { exception.expect(IllegalArgumentException.class); sut.getRequiredInt(EMPTY_PROPERTY); }
@Test public void testGetRequiredIntSpaces() { exception.expect(IllegalArgumentException.class); sut.getRequiredInt(SPACES_PROPERTY); }