summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrabinsk <maciej.grabinski@nokia.com>2019-06-27 12:25:59 +0200
committergrabinsk <maciej.grabinski@nokia.com>2019-06-28 15:15:33 +0200
commit768ab8275b35750ebf46411be54e7bd452a95578 (patch)
treefbd7c81e0dd293daa7a228c9517c6a31baf325d5
parent3e9dc9c5421fe2997e2e5032c6c587c389d9f483 (diff)
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 <maciej.grabinski@nokia.com>
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/bootstrap/CbsBootstrapConfiguration.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java9
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java15
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java4
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/EnvironmentLoaderException.java31
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java16
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java7
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java3
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/TestAppConfiguration.java3
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParserTest.java13
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java1
-rw-r--r--prh-app-server/src/test/resources/configurationFromCbs.json3
12 files changed, 30 insertions, 77 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/bootstrap/CbsBootstrapConfiguration.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/bootstrap/CbsBootstrapConfiguration.java
index 0297a67a..df318550 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/bootstrap/CbsBootstrapConfiguration.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/bootstrap/CbsBootstrapConfiguration.java
@@ -28,7 +28,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
-@EnableConfigurationProperties
+@EnableConfigurationProperties(CbsProperties.class)
public class CbsBootstrapConfiguration {
@Bean
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java
index 84d9fcd2..1d2a65d3 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java
@@ -23,14 +23,12 @@ package org.onap.dcaegen2.services.prh;
import java.util.Map;
import java.util.UUID;
-import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationClient;
import org.slf4j.MDC;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
@@ -41,7 +39,6 @@ import static org.onap.dcaegen2.services.sdk.rest.services.model.logging.MdcVari
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
*/
@SpringBootApplication(exclude = {JacksonAutoConfiguration.class})
-@Configuration
@EnableScheduling
@EnableConfigurationProperties
public class MainApp {
@@ -61,10 +58,4 @@ public class MainApp {
return new ConcurrentTaskScheduler();
}
-
- @Bean
- CloudConfigurationClient getCloudConfigurationClient(){
- return new CloudConfigurationClient();
- }
-
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java
index a57a5393..85b4c035 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java
@@ -69,21 +69,18 @@ class CbsContentParser {
}
MessageRouterPublishRequest getMessageRouterPublishRequest() {
- RawDataStream<JsonObject> sink = DataStreams.namedSinks(jsonObject).find(streamWithName(PNF_READY)).get();
- MessageRouterSink parsedSink = StreamFromGsonParsers.messageRouterSinkParser().unsafeParse(sink);
-
- return ImmutableMessageRouterPublishRequest.builder()
- .contentType(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapContentType").getAsString())
- .sinkDefinition(parsedSink)
- .build();
+ return getMessageRouterPublishRequest(PNF_READY);
}
MessageRouterPublishRequest getMessageRouterUpdatePublishRequest() {
- RawDataStream<JsonObject> sink = DataStreams.namedSinks(jsonObject).find(streamWithName(PNF_UPDATE)).get();
+ return getMessageRouterPublishRequest(PNF_UPDATE);
+ }
+
+ private MessageRouterPublishRequest getMessageRouterPublishRequest(String streamName) {
+ RawDataStream<JsonObject> sink = DataStreams.namedSinks(jsonObject).find(streamWithName(streamName)).get();
MessageRouterSink parsedSink = StreamFromGsonParsers.messageRouterSinkParser().unsafeParse(sink);
return ImmutableMessageRouterPublishRequest.builder()
- .contentType(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapContentType").getAsString())
.sinkDefinition(parsedSink)
.build();
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
index 31794f6b..c21fd400 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
@@ -43,8 +43,8 @@ public class PrhAppConfig {
private Resource gitInfo;
- @EventListener
- public void onApplicationStartedEvent(ApplicationStartedEvent applicationStartedEvent) throws IOException {
+ @EventListener(ApplicationStartedEvent.class)
+ public void onApplicationStarted() throws IOException {
if(LOGGER.isDebugEnabled()) {
LOGGER.debug("Git info={}", StreamUtils.copyToString(gitInfo.getInputStream(), Charset.defaultCharset()));
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/EnvironmentLoaderException.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/EnvironmentLoaderException.java
deleted file mode 100644
index 5fef80d8..00000000
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/EnvironmentLoaderException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.dcaegen2.services.prh.exceptions;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 8/10/18
- */
-public class EnvironmentLoaderException extends Exception {
-
- public EnvironmentLoaderException(String message) {
- super(message);
- }
-}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java
index f49723e2..123eb5a3 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java
@@ -20,21 +20,11 @@
package org.onap.dcaegen2.services.prh.tasks;
-import org.onap.dcaegen2.services.prh.exceptions.AaiNotFoundException;
import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
import reactor.core.publisher.Mono;
-import javax.net.ssl.SSLException;
-
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
- */
-public abstract class AaiProducerTask {
-
- abstract Mono<ConsumerDmaapModel> publish(ConsumerDmaapModel message) throws AaiNotFoundException;
-
- protected abstract Mono<ConsumerDmaapModel> execute(ConsumerDmaapModel consumerDmaapModel)
- throws PrhTaskException, SSLException;
+@FunctionalInterface
+interface AaiProducerTask {
+ Mono<ConsumerDmaapModel> execute(ConsumerDmaapModel consumerDmaapModel) throws PrhTaskException;
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java
index e0dcf0b3..7aaff47d 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java
@@ -39,7 +39,7 @@ import reactor.core.publisher.Mono;
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
*/
@Component
-public class AaiProducerTaskImpl extends AaiProducerTask {
+public class AaiProducerTaskImpl implements AaiProducerTask {
private static final Logger LOGGER = LoggerFactory.getLogger(AaiProducerTaskImpl.class);
@@ -50,8 +50,7 @@ public class AaiProducerTaskImpl extends AaiProducerTask {
this.aaiHttpPatchClient = aaiHttpPatchClient;
}
- @Override
- Mono<ConsumerDmaapModel> publish(ConsumerDmaapModel consumerDmaapModel) {
+ private Mono<ConsumerDmaapModel> publish(ConsumerDmaapModel consumerDmaapModel) {
Mono<HttpResponse> response = aaiHttpPatchClient.getAaiResponse(consumerDmaapModel);
return response.flatMap(r -> {
if (HttpUtils.isSuccessfulResponseCode(r.statusCode())) {
@@ -63,7 +62,7 @@ public class AaiProducerTaskImpl extends AaiProducerTask {
}
@Override
- protected Mono<ConsumerDmaapModel> execute(ConsumerDmaapModel consumerDmaapModel) throws PrhTaskException {
+ public Mono<ConsumerDmaapModel> execute(ConsumerDmaapModel consumerDmaapModel) throws PrhTaskException {
if (consumerDmaapModel == null) {
throw new DmaapNotFoundException("Invoked null object to DMaaP task");
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
index 670d2140..74c6c426 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
@@ -37,7 +37,6 @@ import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
-import javax.net.ssl.SSLException;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
@@ -167,7 +166,7 @@ public class ScheduledTasks {
: aaiProducerTask
.execute(state.dmaapModel)
.map(x -> state);
- } catch (PrhTaskException | SSLException e) {
+ } catch (PrhTaskException e) {
LOGGER.warn("AAIProducerTask exception has been registered: ", e);
return Mono.error(e);
}
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,11 +85,21 @@ 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
diff --git a/prh-app-server/src/test/resources/configurationFromCbs.json b/prh-app-server/src/test/resources/configurationFromCbs.json
index 85dd4de2..d76aab4f 100644
--- a/prh-app-server/src/test/resources/configurationFromCbs.json
+++ b/prh-app-server/src/test/resources/configurationFromCbs.json
@@ -2,17 +2,14 @@
"config":{
"dmaap.dmaapConsumerConfiguration.dmaapUserName":"admin",
"dmaap.dmaapConsumerConfiguration.dmaapUserPassword":"admin",
- "dmaap.dmaapConsumerConfiguration.dmaapContentType":"application/json",
"dmaap.dmaapConsumerConfiguration.consumerId":"c12",
"dmaap.dmaapConsumerConfiguration.consumerGroup":"OpenDCAE-c12",
"dmaap.dmaapConsumerConfiguration.timeoutMs":-1,
"dmaap.dmaapProducerConfiguration.dmaapUserName":"admin",
"dmaap.dmaapProducerConfiguration.dmaapUserPassword":"admin",
- "dmaap.dmaapProducerConfiguration.dmaapContentType":"application/json",
"dmaap.dmaapUpdateProducerConfiguration.dmaapUserName":"admin",
"dmaap.dmaapUpdateProducerConfiguration.dmaapUserPassword":"admin",
- "dmaap.dmaapUpdateProducerConfiguration.dmaapContentType":"application/json",
"aai.aaiClientConfiguration.pnfUrl": "https://aai.onap.svc.cluster.local:8443/aai/v12/network/pnfs/pnf",
"aai.aaiClientConfiguration.aaiUserName":"AAI",
"aai.aaiClientConfiguration.aaiUserPassword":"AAI",