From 768ab8275b35750ebf46411be54e7bd452a95578 Mon Sep 17 00:00:00 2001 From: grabinsk Date: Thu, 27 Jun 2019 12:25:59 +0200 Subject: fix PRH dmaap content type configuration after breaking changes introduced to SDK and mix of minor code cleanups Change-Id: I568f49b8b6635f23b2089a4355eb78451102c2b1 Issue-ID: DCAEGEN2-1647 Signed-off-by: grabinsk --- .../onap/dcaegen2/services/prh/TestAppConfiguration.java | 3 ++- .../prh/configuration/ConsulConfigurationParserTest.java | 13 ++++++++++++- .../services/prh/tasks/DmaapPublisherTaskImplTest.java | 1 - 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'prh-app-server/src/test/java/org') diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/TestAppConfiguration.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/TestAppConfiguration.java index b398c501..c11fe492 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/TestAppConfiguration.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/TestAppConfiguration.java @@ -23,6 +23,7 @@ package org.onap.dcaegen2.services.prh; import org.onap.dcaegen2.services.sdk.model.streams.dmaap.ImmutableMessageRouterSink; import org.onap.dcaegen2.services.sdk.model.streams.dmaap.ImmutableMessageRouterSource; import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.ImmutableAaiClientConfiguration; +import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.ContentType; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.ImmutableMessageRouterPublishRequest; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.ImmutableMessageRouterSubscribeRequest; @@ -44,7 +45,7 @@ public class TestAppConfiguration { public static ImmutableMessageRouterPublishRequest createDefaultMessageRouterPublishRequest() { return ImmutableMessageRouterPublishRequest.builder() - .contentType("application/json") + .contentType(ContentType.APPLICATION_JSON) .sinkDefinition(ImmutableMessageRouterSink.builder() .name("the topic") .topicUrl(String.format("http://%s:%d/events/TOPIC", "www", 1234)) diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParserTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParserTest.java index 79a3873a..3a4db1dd 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParserTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParserTest.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test; import org.onap.dcaegen2.services.prh.TestAppConfiguration; import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration; import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.ImmutableAaiClientConfiguration; +import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.ContentType; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterPublishRequest; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterSubscribeRequest; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.config.MessageRouterPublisherConfig; @@ -84,10 +85,20 @@ class ConsulConfigurationParserTest { MessageRouterPublishRequest messageRouterPublishRequest = consulConfigurationParser.getMessageRouterPublishRequest(); // then - assertThat(messageRouterPublishRequest.contentType()).isEqualTo("application/json"); + assertThat(messageRouterPublishRequest.contentType()).isEqualTo(ContentType.APPLICATION_JSON); assertThat(messageRouterPublishRequest.sinkDefinition().topicUrl()).isEqualTo("http://dmaap-mr:2222/events/unauthenticated.PNF_READY"); } + @Test + void shouldCreateMessageRouterUpdatePublishConfigurationCorrectly() { + // when + MessageRouterPublishRequest messageRouterPublishRequest = consulConfigurationParser.getMessageRouterUpdatePublishRequest(); + + // then + assertThat(messageRouterPublishRequest.contentType()).isEqualTo(ContentType.APPLICATION_JSON); + assertThat(messageRouterPublishRequest.sinkDefinition().topicUrl()).isEqualTo("http://dmaap-mr:2222/events/unauthenticated.PNF_UPDATE"); + } + @Test void whenDmaapCertAuthIsDisabled_MessageRouterPublisherConfigSecurityKeysShouldBeIgnored() { assumeFalse(correctConfig.getAsJsonObject("config").get("security.enableDmaapCertAuth").getAsBoolean()); diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java index a5405069..7e00a441 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java @@ -108,7 +108,6 @@ class DmaapPublisherTaskImplTest { return ImmutableMessageRouterPublishRequest.builder() .sinkDefinition(sinkDefinition) - .contentType("application/json") .build(); } } \ No newline at end of file -- cgit 1.2.3-korg