@Test
public void testValidateAndReplace() {

    final String replacement = UUID.randomUUID().toString();
    // no whitespace
    assertThat(PlaceholderFilter.validateAndReplace("{{thing:namespace}}/{{thing:name}}:{{header:device-id}}",
            replacement, placeholders))
            .isEqualTo(String.format("%s/%s:%s", replacement, replacement, replacement));
    // multi whitespace
    assertThat(PlaceholderFilter.validateAndReplace(
            "{{  thing:namespace  }}/{{  thing:name  }}:{{  header:device-id  }}", replacement, placeholders))
            .isEqualTo(String.format("%s/%s:%s", replacement, replacement, replacement));
    // mixed whitespace
    assertThat(PlaceholderFilter.validateAndReplace("{{thing:namespace }}/{{  thing:name }}:{{header:device-id }}",
            replacement, placeholders))
            .isEqualTo(String.format("%s/%s:%s", replacement, replacement, replacement));
    // no separators
    assertThat(PlaceholderFilter.validateAndReplace("{{thing:namespace }}{{  thing:name }}{{header:device-id }}",
            replacement, placeholders))
            .isEqualTo(String.format("%s%s%s", replacement, replacement, replacement));
    // whitespace separators
    assertThat(
            PlaceholderFilter.validateAndReplace("{{thing:namespace }}  {{  thing:name }}  {{header:device-id }}",
                    replacement, placeholders))
            .isEqualTo(String.format("%s  %s  %s", replacement, replacement, replacement));
    // pre/postfix whitespace
    assertThat(
            PlaceholderFilter.validateAndReplace("  {{thing:namespace }}{{  thing:name }}{{header:device-id }}  ",
                    replacement, placeholders))
            .isEqualTo(String.format("  %s%s%s  ", replacement, replacement, replacement));
    // pre/postfix
    assertThat(PlaceholderFilter.validateAndReplace(
            "-----{{thing:namespace }}{{  thing:name }}{{header:device-id }}-----", replacement, placeholders))
            .isEqualTo(String.format("-----%s%s%s-----", replacement, replacement, replacement));
    // pre/postfix and separators
    assertThat(PlaceholderFilter.validateAndReplace(
            "-----{{thing:namespace }}///{{  thing:name }}///{{header:device-id }}-----", replacement,
            placeholders))
            .isEqualTo(String.format("-----%s///%s///%s-----", replacement, replacement, replacement));
}