From f671ae3ba0802db68ef9d5d9129f95a1a280399d Mon Sep 17 00:00:00 2001 From: Helber Belmiro Date: Tue, 15 Mar 2022 07:47:18 -0300 Subject: [PATCH] =?UTF-8?q?KOGITO-6856=20Added=20verification=20of=20Conte?= =?UTF-8?q?nt-Type=20header=20to=20CloudEventHt=E2=80=A6=20(#2080)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * KOGITO-6856 Added verification of Content-Type header to CloudEventHttpOutgoingDecoratorTest Signed-off-by: Helber Belmiro * KOGITO-6856 Replaced List#of with Collections#singletonList and improved test implementation in CloudEventHttpOutgoingDecoratorTest Signed-off-by: Helber Belmiro --- .../CloudEventHttpOutgoingDecoratorTest.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/quarkus/addons/messaging/common/src/test/java/org/kie/kogito/addon/quarkus/messaging/common/message/CloudEventHttpOutgoingDecoratorTest.java b/quarkus/addons/messaging/common/src/test/java/org/kie/kogito/addon/quarkus/messaging/common/message/CloudEventHttpOutgoingDecoratorTest.java index d1588594572..ad36bbe882e 100644 --- a/quarkus/addons/messaging/common/src/test/java/org/kie/kogito/addon/quarkus/messaging/common/message/CloudEventHttpOutgoingDecoratorTest.java +++ b/quarkus/addons/messaging/common/src/test/java/org/kie/kogito/addon/quarkus/messaging/common/message/CloudEventHttpOutgoingDecoratorTest.java @@ -15,6 +15,9 @@ */ package org.kie.kogito.addon.quarkus.messaging.common.message; +import java.util.Collections; +import java.util.Optional; + import javax.inject.Inject; import org.eclipse.microprofile.reactive.messaging.Message; @@ -33,15 +36,9 @@ class CloudEventHttpOutgoingDecoratorTest { @Test void verifyOutgoingHttpMetadataIsSet() { - Message message = Message.of("pepe"); - message = provider.decorate(message); - assertThat(message.getMetadata(OutgoingHttpMetadata.class)).isNotEmpty(); - - /* - * It would be nice to check if the Content-Type header has the value "application/cloudevents+json". - * But as far as we know, there's no way to test the actual headers, since OutgoingHttpMetadata#getHeaders is not public. - * - * https://quarkusio.zulipchat.com/#narrow/stream/294206-smallrye/topic/OutgoingHttpMetadata.20has.20no.20public.20methods/near/274438268 - */ + Message message = provider.decorate(Message.of("pepe")); + Optional metadata = message.getMetadata(OutgoingHttpMetadata.class); + assertThat(metadata).isNotEmpty(); + assertThat(metadata.orElseThrow().getHeaders()).containsEntry("Content-Type", Collections.singletonList("application/cloudevents+json")); } }