ImmutablePlaceholderResolver implements PlaceholderResolver<T> { @Override public Optional<String> resolve(final T placeholderSource, final String name) { return placeholder.resolve(placeholderSource, name); } ImmutablePlaceholderResolver(final Placeholder<T> placeholder, @Nullable final T placeholderSource); @Override Optional<T> getPlaceholderSource(); @Override Optional<String> resolve(final T placeholderSource, final String name); @Override String getPrefix(); @Override List<String> getSupportedNames(); @Override boolean supports(final String name); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testPlaceholderResolvementBasedOnMap() { final Map<String, String> inputMap = new HashMap<>(); inputMap.put("one", "1"); inputMap.put("two", "2"); final ImmutablePlaceholderResolver<Map<String, String>> underTest = new ImmutablePlaceholderResolver<>( PlaceholderFactory.newHeadersPlaceholder(), inputMap); assertThat(underTest.resolve("one")) .contains("1"); assertThat(underTest.resolve("two")) .contains("2"); }
@Test public void testPlaceholderResolvementBasedOnTopic() { final String fullPath = "org.eclipse.ditto/foo23/things/twin/commands/modify"; final TopicPath topic = ProtocolFactory.newTopicPath(fullPath); final ImmutablePlaceholderResolver<TopicPath> underTest = new ImmutablePlaceholderResolver<>( PlaceholderFactory.newTopicPathPlaceholder(), topic); assertThat(underTest.resolve("full")) .contains(fullPath); assertThat(underTest.resolve("namespace")) .contains("org.eclipse.ditto"); assertThat(underTest.resolve("entityId")) .contains("foo23"); assertThat(underTest.resolve("group")) .contains("things"); assertThat(underTest.resolve("channel")) .contains("twin"); assertThat(underTest.resolve("criterion")) .contains("commands"); assertThat(underTest.resolve("action")) .contains("modify"); }