Skip to content

Commit

Permalink
KOGITO-6856 Added verification of Content-Type header to CloudEventHt… (
Browse files Browse the repository at this point in the history
#2080)

* KOGITO-6856 Added verification of Content-Type header to CloudEventHttpOutgoingDecoratorTest

Signed-off-by: Helber Belmiro <[email protected]>

* KOGITO-6856 Replaced List#of with Collections#singletonList and improved test implementation in CloudEventHttpOutgoingDecoratorTest

Signed-off-by: Helber Belmiro <[email protected]>
  • Loading branch information
hbelmiro authored Mar 15, 2022
1 parent a0fc933 commit f671ae3
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,15 +36,9 @@ class CloudEventHttpOutgoingDecoratorTest {

@Test
void verifyOutgoingHttpMetadataIsSet() {
Message<String> 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<String> message = provider.decorate(Message.of("pepe"));
Optional<OutgoingHttpMetadata> metadata = message.getMetadata(OutgoingHttpMetadata.class);
assertThat(metadata).isNotEmpty();
assertThat(metadata.orElseThrow().getHeaders()).containsEntry("Content-Type", Collections.singletonList("application/cloudevents+json"));
}
}

0 comments on commit f671ae3

Please sign in to comment.