From af3011aa4397e1fd05adb495e462ac91f453299d Mon Sep 17 00:00:00 2001 From: Yannic Klem Date: Tue, 5 May 2020 09:50:00 +0200 Subject: [PATCH 1/3] remove filtering of headers for adaptables Signed-off-by: Yannic Klem --- .../protocoladapter/AbstractAdapter.java | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/protocol-adapter/src/main/java/org/eclipse/ditto/protocoladapter/AbstractAdapter.java b/protocol-adapter/src/main/java/org/eclipse/ditto/protocoladapter/AbstractAdapter.java index de73abe645..03c6853685 100755 --- a/protocol-adapter/src/main/java/org/eclipse/ditto/protocoladapter/AbstractAdapter.java +++ b/protocol-adapter/src/main/java/org/eclipse/ditto/protocoladapter/AbstractAdapter.java @@ -152,29 +152,11 @@ private static DittoHeaders mapTopicPathToHeaders(final TopicPath topicPath) { @Override public final Adaptable toAdaptable(final T signal, final TopicPath.Channel channel) { final Adaptable adaptable = mapSignalToAdaptable(signal, channel); - final Map externalHeaders; - if (filterOutUnknownExternalHeaders(signal, channel)) { - externalHeaders = headerTranslator.toExternalAndRetainKnownHeaders(adaptable.getDittoHeaders()); - } else { - externalHeaders = headerTranslator.toExternalHeaders(adaptable.getDittoHeaders()); - } + final Map externalHeaders = headerTranslator.toExternalHeaders(adaptable.getDittoHeaders()); return adaptable.setDittoHeaders(DittoHeaders.of(externalHeaders)); } - /** - * Called in order to determine whether to filter out unknown headers (then return {@code true}) or to keep all - * unknown headers (then return {@code false}). - * By default for CommandResponses the unknown headers will be filtered. - * - * @param signal the signal which can be used to determine the decision on. - * @param channel the channel of the signal. - * @return {@code true} when unknown external headers should be filtered, {@code false} otherwise. - */ - protected boolean filterOutUnknownExternalHeaders(final T signal, final TopicPath.Channel channel) { - return channel == TopicPath.Channel.TWIN && signal instanceof CommandResponse; - } - /** * Subclasses must implement the method to map from the given {@link org.eclipse.ditto.signals.base.Signal} to an * {@link Adaptable}. From d8141297498f6ed9e79cb4a513d2e37794d93f62 Mon Sep 17 00:00:00 2001 From: Yannic Klem Date: Tue, 5 May 2020 13:56:44 +0200 Subject: [PATCH 2/3] remove deprecated usage of verifyZeroInteractions Signed-off-by: Yannic Klem --- ...ipelineFunctionParameterResolverFactoryTest.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/model/placeholders/src/test/java/org/eclipse/ditto/model/placeholders/PipelineFunctionParameterResolverFactoryTest.java b/model/placeholders/src/test/java/org/eclipse/ditto/model/placeholders/PipelineFunctionParameterResolverFactoryTest.java index 0cd36fb6be..6675e831e1 100644 --- a/model/placeholders/src/test/java/org/eclipse/ditto/model/placeholders/PipelineFunctionParameterResolverFactoryTest.java +++ b/model/placeholders/src/test/java/org/eclipse/ditto/model/placeholders/PipelineFunctionParameterResolverFactoryTest.java @@ -17,7 +17,8 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; import java.util.function.Predicate; @@ -45,7 +46,7 @@ public void singleStringResolverAcceptsDoubleQuotes() { final String params = "(\"" + KNOWN_VALUE + "\")"; assertThat(parameterResolver.apply(params, expressionResolver, DUMMY)).contains(KNOWN_VALUE); - verifyZeroInteractions(expressionResolver); + verifyNoInteractions(expressionResolver); } @Test @@ -56,7 +57,7 @@ public void singleStringResolverAcceptsSingleQuotes() { final String params = "(\'" + KNOWN_VALUE + "\')"; assertThat(parameterResolver.apply(params, expressionResolver, DUMMY)).contains(KNOWN_VALUE); - verifyZeroInteractions(expressionResolver); + verifyNoInteractions(expressionResolver); } @Test @@ -75,7 +76,7 @@ public void singleResolverThrowsExceptionOnMultipleParameters() { assertThatExceptionOfType(PlaceholderFunctionSignatureInvalidException.class) .isThrownBy(() -> parameterResolver.apply(paramsPlaceholders, expressionResolver, DUMMY)); - verifyZeroInteractions(expressionResolver); + verifyNoInteractions(expressionResolver); } @Test @@ -147,7 +148,7 @@ public void singleStringResolverThrowsExceptionIfNotResolvable() { assertThatExceptionOfType(PlaceholderFunctionSignatureInvalidException.class) .isThrownBy(() -> stringResolver.apply(stringPlaceholder, expressionResolver, DUMMY)); - verifyZeroInteractions(expressionResolver); + verifyNoInteractions(expressionResolver); } @Test @@ -164,7 +165,7 @@ public void singleStringResolverDoesNotResolvePlaceholders() { assertThatExceptionOfType(PlaceholderFunctionSignatureInvalidException.class) .isThrownBy(() -> stringResolver.apply(stringPlaceholder, expressionResolver, DUMMY)); - verifyZeroInteractions(expressionResolver); + verifyNoInteractions(expressionResolver); } @Test From a7f531c9cf64d4e44dfd4f18a00d9ef0df5b761d Mon Sep 17 00:00:00 2001 From: Yufei Cai Date: Tue, 5 May 2020 21:00:05 +0200 Subject: [PATCH 3/3] Issue #671: Remove unused imports. Signed-off-by: Yufei Cai --- .../PipelineFunctionParameterResolverFactoryTest.java | 2 -- .../java/org/eclipse/ditto/protocoladapter/AbstractAdapter.java | 1 - 2 files changed, 3 deletions(-) diff --git a/model/placeholders/src/test/java/org/eclipse/ditto/model/placeholders/PipelineFunctionParameterResolverFactoryTest.java b/model/placeholders/src/test/java/org/eclipse/ditto/model/placeholders/PipelineFunctionParameterResolverFactoryTest.java index 6675e831e1..1e597afb6b 100644 --- a/model/placeholders/src/test/java/org/eclipse/ditto/model/placeholders/PipelineFunctionParameterResolverFactoryTest.java +++ b/model/placeholders/src/test/java/org/eclipse/ditto/model/placeholders/PipelineFunctionParameterResolverFactoryTest.java @@ -15,10 +15,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; -import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; import java.util.function.Predicate; diff --git a/protocol-adapter/src/main/java/org/eclipse/ditto/protocoladapter/AbstractAdapter.java b/protocol-adapter/src/main/java/org/eclipse/ditto/protocoladapter/AbstractAdapter.java index 03c6853685..d1820c6516 100755 --- a/protocol-adapter/src/main/java/org/eclipse/ditto/protocoladapter/AbstractAdapter.java +++ b/protocol-adapter/src/main/java/org/eclipse/ditto/protocoladapter/AbstractAdapter.java @@ -26,7 +26,6 @@ import org.eclipse.ditto.model.base.headers.DittoHeadersBuilder; import org.eclipse.ditto.model.base.json.Jsonifiable; import org.eclipse.ditto.protocoladapter.adaptables.MappingStrategies; -import org.eclipse.ditto.signals.commands.base.CommandResponse; /** * Abstract implementation of {@link Adapter} to provide common functionality.