ConfigMapper { static void validateDelimiter(final String serialisedForm, final int delimiterPosition, final String positionName, final String exampleText) { if (serialisedForm.length() < delimiterPosition + 1) { throw new RuntimeException(LogUtil.message("Delimiter position {} is out of bounds for {}", delimiterPosition, serialisedForm)); } final String delimiter = String.valueOf(serialisedForm.charAt(delimiterPosition)); if (!VALID_DELIMITERS_SET.contains(delimiter)) { throw new RuntimeException(LogUtil.message( "[{}] does not contain a valid delimiter as its {} character. " + "Valid delimiters are [{}]. " + "For example [{}]", serialisedForm, positionName, String.join("", VALID_DELIMITERS_LIST), exampleText)); } } @Inject  ConfigMapper(final AppConfig appConfig); static void decorateWithPropertyPaths(final AppConfig appConfig); boolean validatePropertyPath(final PropertyPath fullPath); Optional<Prop> getProp(final PropertyPath propertyPath); static final String LIST_EXAMPLE; static final String MAP_EXAMPLE; static final String DOCREF_EXAMPLE; }
@Test void testValidateDelimiter_good() { ConfigMapper.validateDelimiter("|a|b|c", 0, "first", "dummy example"); }
@Test void testValidateDelimiter_bad() { Assertions.assertThrows(RuntimeException.class, () -> { ConfigMapper.validateDelimiter("xxxx", 0, "first", "dummy example"); }); }