PlaceholderFilter { public static String validateAndReplace(final String template, final String stringUsedInPlaceholderReplacement, final Placeholder<?>... placeholders) { return doApply(template, PlaceholderFactory.newExpressionResolverForValidation(stringUsedInPlaceholderReplacement, placeholders) ); } private  PlaceholderFilter(); static AuthorizationContext applyHeadersPlaceholderToAuthContext(
            final AuthorizationContext authorizationContext,
            final Map<String, String> headers); static String apply(final String template, final T placeholderSource, final Placeholder<T> placeholder); static String apply(final String template, final ExpressionResolver expressionResolver); static Optional<String> applyOrElseDelete(final String template, final ExpressionResolver resolver); static String applyOrElseRetain(final String template, final ExpressionResolver resolver); static void validate(final String template, final Placeholder<?>... placeholders); static String validateAndReplace(final String template, final String stringUsedInPlaceholderReplacement,
            final Placeholder<?>... placeholders);  }
@Test public void testValidateAndReplace() { final String replacement = UUID.randomUUID().toString(); assertThat(PlaceholderFilter.validateAndReplace("{{thing:namespace}}/{{thing:name}}:{{header:device-id}}", replacement, placeholders)) .isEqualTo(String.format("%s/%s:%s", replacement, replacement, replacement)); assertThat(PlaceholderFilter.validateAndReplace( "{{ thing:namespace }}/{{ thing:name }}:{{ header:device-id }}", replacement, placeholders)) .isEqualTo(String.format("%s/%s:%s", replacement, replacement, replacement)); assertThat(PlaceholderFilter.validateAndReplace("{{thing:namespace }}/{{ thing:name }}:{{header:device-id }}", replacement, placeholders)) .isEqualTo(String.format("%s/%s:%s", replacement, replacement, replacement)); assertThat(PlaceholderFilter.validateAndReplace("{{thing:namespace }}{{ thing:name }}{{header:device-id }}", replacement, placeholders)) .isEqualTo(String.format("%s%s%s", replacement, replacement, replacement)); assertThat( PlaceholderFilter.validateAndReplace("{{thing:namespace }} {{ thing:name }} {{header:device-id }}", replacement, placeholders)) .isEqualTo(String.format("%s %s %s", replacement, replacement, replacement)); assertThat( PlaceholderFilter.validateAndReplace(" {{thing:namespace }}{{ thing:name }}{{header:device-id }} ", replacement, placeholders)) .isEqualTo(String.format(" %s%s%s ", replacement, replacement, replacement)); assertThat(PlaceholderFilter.validateAndReplace( "-----{{thing:namespace }}{{ thing:name }}{{header:device-id }}-----", replacement, placeholders)) .isEqualTo(String.format("-----%s%s%s-----", replacement, replacement, replacement)); assertThat(PlaceholderFilter.validateAndReplace( "-----{{thing:namespace }} placeholders)) .isEqualTo(String.format("-----%s }