CheckExternalFilter extends AbstractHeaderEntryFilter { public static CheckExternalFilter shouldWriteToExternal(final Map<String, HeaderDefinition> headerDefinitions) { return new CheckExternalFilter(headerDefinitions, isNull().or(HeaderDefinition::shouldWriteToExternalHeaders)); } private  CheckExternalFilter(final Map<String, HeaderDefinition> headerDefinitions,
            final Predicate<HeaderDefinition> headerDefinitionPredicate); static CheckExternalFilter shouldReadFromExternal(final Map<String, HeaderDefinition> headerDefinitions); static CheckExternalFilter shouldWriteToExternal(final Map<String, HeaderDefinition> headerDefinitions); static CheckExternalFilter existsAsHeaderDefinition(final Map<String, HeaderDefinition> headerDefinitions);  }
@Test public void tryToGetShouldWriteToExternalInstanceWithNullHeaderDefinitions() { assertThatNullPointerException() .isThrownBy(() -> CheckExternalFilter.shouldWriteToExternal(null)) .withMessage("The headerDefinitions must not be null!") .withNoCause(); }
@Test public void filterValueWithoutMatchingHeaderDefinitionShouldWriteToExternal() { final String key = "foo"; final String value = "bar"; final CheckExternalFilter underTest = CheckExternalFilter.shouldWriteToExternal(Collections.emptyMap()); assertThat(underTest.apply(key, value)).isEqualTo(value); }
@Test public void filterValueThatShouldBeExposedExternally() { final DittoHeaderDefinition headerDefinition = DittoHeaderDefinition.CORRELATION_ID; final String value = "correlation-id"; final Map<String, HeaderDefinition> headerDefinitions = Maps.newHashMap(headerDefinition.getKey(), headerDefinition); final CheckExternalFilter underTest = CheckExternalFilter.shouldWriteToExternal(headerDefinitions); assertThat(underTest.apply(headerDefinition.getKey(), value)).isEqualTo(value); }