DefaultMetadataHeaderKey implements MetadataHeaderKey { public static DefaultMetadataHeaderKey of(final JsonPointer path) { final DefaultMetadataHeaderKey result = new DefaultMetadataHeaderKey(checkNotNull(path, "path")); result.validate(); return result; } private  DefaultMetadataHeaderKey(final JsonPointer path); static DefaultMetadataHeaderKey parse(final CharSequence key); static DefaultMetadataHeaderKey of(final JsonPointer path); @Override boolean appliesToAllLeaves(); @Override JsonPointer getPath(); @Override int compareTo(final MetadataHeaderKey other); @Override boolean equals(@Nullable final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void tryToGetInstanceWithNullPath() { assertThatNullPointerException() .isThrownBy(() -> DefaultMetadataHeaderKey.of(null)) .withMessage("The path must not be null!") .withNoCause(); }
@Test public void tryToGetInstanceWithEmptyPath() { assertThatIllegalArgumentException() .isThrownBy(() -> DefaultMetadataHeaderKey.of(JsonPointer.empty())) .withMessage("The path of a metadata header key must not be empty!") .withNoCause(); }
@Test public void wildcardPathHasTooFewLevels() { assertThatIllegalArgumentException() .isThrownBy(() -> DefaultMetadataHeaderKey.of(JsonPointer.of("/*"))) .withMessage("A wildcard path of a metadata header key must have exactly two levels but it had <1>!") .withNoCause(); }
@Test public void wildcardPathHasTooManyLevels() { assertThatIllegalArgumentException() .isThrownBy(() -> DefaultMetadataHeaderKey.of(JsonPointer.of("/*/foo/meta"))) .withMessage("A wildcard path of a metadata header key must have exactly two levels but it had <3>!") .withNoCause(); }
@Test public void wildcardPathHasAsteriskLeaf() { assertThatIllegalArgumentException() .isThrownBy(() -> DefaultMetadataHeaderKey.of(JsonPointer.of("/*/*"))) .withMessage("The path of a metadata header key must not contain <*> at level <1>!") .withNoCause(); }
@Test public void pathContainsAsteriskAtWrongLevel() { assertThatIllegalArgumentException() .isThrownBy(() -> DefaultMetadataHeaderKey.of(JsonPointer.of("/foo/*/baz"))) .withMessage("The path of a metadata header key must not contain <*> at level <1>!") .withNoCause(); }