MigrationProperties extends Properties { public String getRequiredString(String property) { String prop = getStringOrNull(property); if (prop == null) { throw new IllegalArgumentException("Required property " + property + " missing"); } return prop; } 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 testGetRequiredStringValid() { assertEquals(VALID_STRING_VALUE, sut.getRequiredString(VALID_STRING)); }
@Test public void testGetRequiredStringNeedsTrimmed() { assertEquals(VALID_STRING_VALUE, sut.getRequiredString(NEEDS_TRIMMED_STRING)); }
@Test public void testGetRequiredStringMissing() { exception.expect(IllegalArgumentException.class); sut.getRequiredString(MISSING_PROPERTY); }
@Test public void testGetRequiredStringEmpty() { exception.expect(IllegalArgumentException.class); sut.getRequiredString(EMPTY_PROPERTY); }
@Test public void testGetRequiredStringSpaces() { exception.expect(IllegalArgumentException.class); sut.getRequiredString(SPACES_PROPERTY); }