diff options
author | pwielebs <piotr.wielebski@nokia.com> | 2019-04-10 14:38:36 +0200 |
---|---|---|
committer | pwielebs <piotr.wielebski@nokia.com> | 2019-04-10 14:58:41 +0200 |
commit | 315fbc568d80baa85ad5989b3faae9aa199c3d9c (patch) | |
tree | 12268eb5dbf48da3ea7344389fbf7fea25518749 /prh-app-server/src | |
parent | 74d946d67bb3da606ec8e7633f69963ad06cd568 (diff) |
use CBS SDK in PRH (II)
-remove unused classes
-fix junit tests
-use cbs
-patch project version updated
Change-Id: I5fb63408b33b07632eab579d028070eb3a025865
Issue-ID: DCAEGEN2-1360
Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'prh-app-server/src')
25 files changed, 228 insertions, 747 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java index 6df9c4ac..0d20c39c 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java @@ -42,7 +42,7 @@ import java.util.function.BiFunction; @Configuration public class AaiHttpClientConfig { @Autowired - private ConsulConfiguration consulConfiguration; + private CbsConfiguration cbsConfiguration; @Bean public AaiHttpClient<AaiModel, HttpResponse> getPatchClientFactory() { @@ -68,8 +68,8 @@ public class AaiHttpClientConfig { final BiFunction<AaiClientConfiguration, CloudHttpClient, AaiHttpClient<T, U>> factoryMethod) { return x -> factoryMethod.apply( - consulConfiguration.getAaiClientConfiguration(), - new AaiHttpClientFactory(consulConfiguration.getAaiClientConfiguration()).build() + cbsConfiguration.getAaiClientConfiguration(), + new AaiHttpClientFactory(cbsConfiguration.getAaiClientConfiguration()).build() ).getAaiResponse(x); } } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java deleted file mode 100644 index 8ac1d9c0..00000000 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java +++ /dev/null @@ -1,359 +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.configuration; - -import java.util.Objects; -import java.util.Optional; -import java.util.function.Predicate; -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.config.DmaapConsumerConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapConsumerConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapPublisherConfiguration; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -/** - * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18 - */ -@Configuration -@EnableConfigurationProperties -public class AppConfig extends PrhAppConfig { - - private static Predicate<String> isEmpty = String::isEmpty; - @Value("${dmaap.dmaapConsumerConfiguration.dmaapHostName:}") - public String consumerDmaapHostName; - - @Value("${dmaap.dmaapConsumerConfiguration.dmaapPortNumber:}") - public Integer consumerDmaapPortNumber; - - @Value("${dmaap.dmaapConsumerConfiguration.dmaapTopicName:}") - public String consumerDmaapTopicName; - - @Value("${dmaap.dmaapConsumerConfiguration.dmaapProtocol:}") - public String consumerDmaapProtocol; - - @Value("${dmaap.dmaapConsumerConfiguration.dmaapUserName:}") - public String consumerDmaapUserName; - - @Value("${dmaap.dmaapConsumerConfiguration.dmaapUserPassword:}") - public String consumerDmaapUserPassword; - - @Value("${dmaap.dmaapConsumerConfiguration.dmaapContentType:}") - public String consumerDmaapContentType; - - @Value("${dmaap.dmaapConsumerConfiguration.consumerId:}") - public String consumerId; - - @Value("${dmaap.dmaapConsumerConfiguration.consumerGroup:}") - public String consumerGroup; - - @Value("${dmaap.dmaapConsumerConfiguration.timeoutMs:}") - public Integer consumerTimeoutMs; - - @Value("${dmaap.dmaapConsumerConfiguration.message-limit:}") - public Integer consumerMessageLimit; - - @Value("${dmaap.dmaapProducerConfiguration.dmaapHostName:}") - public String producerDmaapHostName; - - @Value("${dmaap.dmaapProducerConfiguration.dmaapPortNumber:}") - public Integer producerDmaapPortNumber; - - @Value("${dmaap.dmaapProducerConfiguration.dmaapTopicName:}") - public String producerDmaapTopicName; - - @Value("${dmaap.dmaapProducerConfiguration.dmaapProtocol:}") - public String producerDmaapProtocol; - - @Value("${dmaap.dmaapProducerConfiguration.dmaapUserName:}") - public String producerDmaapUserName; - - @Value("${dmaap.dmaapProducerConfiguration.dmaapUserPassword:}") - public String producerDmaapUserPassword; - - @Value("${dmaap.dmaapProducerConfiguration.dmaapContentType:}") - public String producerDmaapContentType; - - @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapHostName:}") - public String updateProducerDmaapHostName; - - @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapPortNumber:}") - public Integer updateProducerDmaapPortNumber; - - @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapTopicName:}") - public String updateProducerDmaapTopicName; - - @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapProtocol:}") - public String updateProducerDmaapProtocol; - - @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapUserName:}") - public String updateProducerDmaapUserName; - - @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapUserPassword:}") - public String updateProducerDmaapUserPassword; - - @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapContentType:}") - public String updateProducerDmaapContentType; - - @Value("${aai.aaiClientConfiguration.pnfUrl:}") - public String pnfUrl; - - @Value("${aai.aaiClientConfiguration.aaiHost:}") - public String aaiHost; - - @Value("${aai.aaiClientConfiguration.aaiHostPortNumber:}") - public Integer aaiPort; - - @Value("${aai.aaiClientConfiguration.aaiProtocol:}") - public String aaiProtocol; - - @Value("${aai.aaiClientConfiguration.aaiUserName:}") - public String aaiUserName; - - @Value("${aai.aaiClientConfiguration.aaiUserPassword:}") - public String aaiUserPassword; - - @Value("${aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors:}") - public Boolean aaiIgnoreSslCertificateErrors; - - @Value("${aai.aaiClientConfiguration.aaiBasePath:}") - public String aaiBasePath; - - @Value("${aai.aaiClientConfiguration.aaiPnfPath:}") - public String aaiPnfPath; - - @Value("${aai.aaiClientConfiguration.aaiServiceInstancePath:}") - public String aaiServiceInstancePath; - - @Value("${security.trustStorePath:}") - public String trustStorePath; - - @Value("${security.trustStorePasswordPath:}") - public String trustStorePasswordPath; - - @Value("${security.keyStorePath:}") - public String keyStorePath; - - @Value("${security.keyStorePasswordPath:}") - public String keyStorePasswordPath; - - @Value("${security.enableAaiCertAuth:}") - public Boolean enableAaiCertAuth; - - @Value("${security.enableDmaapCertAuth:}") - public Boolean enableDmaapCertAuth; - - @Override - public DmaapConsumerConfiguration getDmaapConsumerConfiguration() { - if (noFileConfiguration(dmaapConsumerConfiguration)) { - return null; - } - return new ImmutableDmaapConsumerConfiguration.Builder() - .dmaapUserPassword( - Optional.ofNullable(consumerDmaapUserPassword).filter(isEmpty.negate()) - .orElse(dmaapConsumerConfiguration.dmaapUserPassword())) - .dmaapUserName( - Optional.ofNullable(consumerDmaapUserName).filter(isEmpty.negate()) - .orElse(dmaapConsumerConfiguration.dmaapUserName())) - .dmaapHostName( - Optional.ofNullable(consumerDmaapHostName).filter(isEmpty.negate()) - .orElse(dmaapConsumerConfiguration.dmaapHostName())) - .dmaapPortNumber( - Optional.ofNullable(consumerDmaapPortNumber).filter(p -> !p.toString().isEmpty()) - .orElse(dmaapConsumerConfiguration.dmaapPortNumber())) - .dmaapProtocol( - Optional.ofNullable(consumerDmaapProtocol).filter(isEmpty.negate()) - .orElse(dmaapConsumerConfiguration.dmaapProtocol())) - .dmaapContentType( - Optional.ofNullable(consumerDmaapContentType).filter(isEmpty.negate()) - .orElse(dmaapConsumerConfiguration.dmaapContentType())) - .dmaapTopicName( - Optional.ofNullable(consumerDmaapTopicName).filter(isEmpty.negate()) - .orElse(dmaapConsumerConfiguration.dmaapTopicName())) - .messageLimit( - Optional.ofNullable(consumerMessageLimit).filter(p -> !p.toString().isEmpty()) - .orElse(dmaapConsumerConfiguration.messageLimit())) - .timeoutMs(Optional.ofNullable(consumerTimeoutMs).filter(p -> !p.toString().isEmpty()) - .orElse(dmaapConsumerConfiguration.timeoutMs())) - .consumerGroup(Optional.ofNullable(consumerGroup).filter(isEmpty.negate()) - .orElse(dmaapConsumerConfiguration.consumerGroup())) - .consumerId(Optional.ofNullable(consumerId).filter(isEmpty.negate()) - .orElse(dmaapConsumerConfiguration.consumerId())) - .trustStorePath( - Optional.ofNullable(trustStorePath).filter(isEmpty.negate()) - .orElse(dmaapConsumerConfiguration.trustStorePath())) - .trustStorePasswordPath( - Optional.ofNullable(trustStorePasswordPath).filter(isEmpty.negate()) - .orElse(dmaapConsumerConfiguration.trustStorePasswordPath())) - .keyStorePath( - Optional.ofNullable(keyStorePath).filter(isEmpty.negate()) - .orElse(dmaapConsumerConfiguration.keyStorePath())) - .keyStorePasswordPath( - Optional.ofNullable(keyStorePasswordPath).filter(isEmpty.negate()) - .orElse(dmaapConsumerConfiguration.keyStorePasswordPath())) - .enableDmaapCertAuth( - Optional.ofNullable(enableDmaapCertAuth).filter(p -> !p.toString().isEmpty()) - .orElse(dmaapConsumerConfiguration.enableDmaapCertAuth())) - .build(); - } - - @Override - public AaiClientConfiguration getAaiClientConfiguration() { - if (noFileConfiguration(aaiClientConfiguration)) { - return null; - } - return new ImmutableAaiClientConfiguration.Builder() - .pnfUrl(Optional.ofNullable(pnfUrl).filter(isEmpty.negate()).orElse(aaiClientConfiguration.pnfUrl())) - .aaiHost(Optional.ofNullable(aaiHost).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiHost())) - .aaiPort( - Optional.ofNullable(aaiPort).filter(p -> !p.toString().isEmpty()) - .orElse(aaiClientConfiguration.aaiPort())) - .aaiIgnoreSslCertificateErrors( - Optional.ofNullable(aaiIgnoreSslCertificateErrors).filter(p -> !p.toString().isEmpty()) - .orElse(aaiClientConfiguration.aaiIgnoreSslCertificateErrors())) - .aaiProtocol( - Optional.ofNullable(aaiProtocol).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiProtocol())) - .aaiUserName( - Optional.ofNullable(aaiUserName).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiUserName())) - .aaiUserPassword(Optional.ofNullable(aaiUserPassword).filter(isEmpty.negate()) - .orElse(aaiClientConfiguration.aaiUserPassword())) - .aaiBasePath(Optional.ofNullable(aaiBasePath).filter(isEmpty.negate()) - .orElse(aaiClientConfiguration.aaiBasePath())) - .aaiPnfPath( - Optional.ofNullable(aaiPnfPath).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiPnfPath())) - .aaiServiceInstancePath( - Optional.ofNullable(aaiServiceInstancePath).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiServiceInstancePath())) - .aaiHeaders(aaiClientConfiguration.aaiHeaders()) - .trustStorePath( - Optional.ofNullable(trustStorePath).filter(isEmpty.negate()) - .orElse(aaiClientConfiguration.trustStorePath())) - .trustStorePasswordPath( - Optional.ofNullable(trustStorePasswordPath).filter(isEmpty.negate()) - .orElse(aaiClientConfiguration.trustStorePasswordPath())) - .keyStorePath( - Optional.ofNullable(keyStorePath).filter(isEmpty.negate()) - .orElse(aaiClientConfiguration.keyStorePath())) - .keyStorePasswordPath( - Optional.ofNullable(keyStorePasswordPath).filter(isEmpty.negate()) - .orElse(aaiClientConfiguration.keyStorePasswordPath())) - .enableAaiCertAuth( - Optional.ofNullable(enableAaiCertAuth).filter(p -> !p.toString().isEmpty()) - .orElse(aaiClientConfiguration.enableAaiCertAuth())) - .build(); - } - - @Override - public DmaapPublisherConfiguration getDmaapPublisherConfiguration() { - if (noFileConfiguration(dmaapPublisherConfiguration)) { - return null; - } - return new ImmutableDmaapPublisherConfiguration.Builder() - .dmaapContentType( - Optional.ofNullable(producerDmaapContentType).filter(isEmpty.negate()) - .orElse(dmaapPublisherConfiguration.dmaapContentType())) - .dmaapHostName( - Optional.ofNullable(producerDmaapHostName).filter(isEmpty.negate()) - .orElse(dmaapPublisherConfiguration.dmaapHostName())) - .dmaapPortNumber( - Optional.ofNullable(producerDmaapPortNumber).filter(p -> !p.toString().isEmpty()) - .orElse(dmaapPublisherConfiguration.dmaapPortNumber())) - .dmaapProtocol( - Optional.ofNullable(producerDmaapProtocol).filter(isEmpty.negate()) - .orElse(dmaapPublisherConfiguration.dmaapProtocol())) - .dmaapTopicName( - Optional.ofNullable(producerDmaapTopicName).filter(isEmpty.negate()) - .orElse(dmaapPublisherConfiguration.dmaapTopicName())) - .dmaapUserName( - Optional.ofNullable(producerDmaapUserName).filter(isEmpty.negate()) - .orElse(dmaapPublisherConfiguration.dmaapUserName())) - .dmaapUserPassword( - Optional.ofNullable(producerDmaapUserPassword).filter(isEmpty.negate()) - .orElse(dmaapPublisherConfiguration.dmaapUserPassword())) - .trustStorePath( - Optional.ofNullable(trustStorePath).filter(isEmpty.negate()) - .orElse(dmaapPublisherConfiguration.trustStorePath())) - .trustStorePasswordPath( - Optional.ofNullable(trustStorePasswordPath).filter(isEmpty.negate()) - .orElse(dmaapPublisherConfiguration.trustStorePasswordPath())) - .keyStorePath( - Optional.ofNullable(keyStorePath).filter(isEmpty.negate()) - .orElse(dmaapPublisherConfiguration.keyStorePath())) - .keyStorePasswordPath( - Optional.ofNullable(keyStorePasswordPath).filter(isEmpty.negate()) - .orElse(dmaapPublisherConfiguration.keyStorePasswordPath())) - .enableDmaapCertAuth( - Optional.ofNullable(enableDmaapCertAuth).filter(p -> !p.toString().isEmpty()) - .orElse(dmaapPublisherConfiguration.enableDmaapCertAuth())) - .build(); - } - - @Override - public DmaapPublisherConfiguration getDmaapUpdatePublisherConfiguration() { - if (noFileConfiguration(dmaapUpdatePublisherConfiguration)) { - return null; - } - return new ImmutableDmaapPublisherConfiguration.Builder() - .dmaapContentType( - Optional.ofNullable(updateProducerDmaapContentType).filter(isEmpty.negate()) - .orElse(dmaapUpdatePublisherConfiguration.dmaapContentType())) - .dmaapHostName( - Optional.ofNullable(updateProducerDmaapHostName).filter(isEmpty.negate()) - .orElse(dmaapUpdatePublisherConfiguration.dmaapHostName())) - .dmaapPortNumber( - Optional.ofNullable(updateProducerDmaapPortNumber).filter(p -> !p.toString().isEmpty()) - .orElse(dmaapPublisherConfiguration.dmaapPortNumber())) - .dmaapProtocol( - Optional.ofNullable(updateProducerDmaapProtocol).filter(isEmpty.negate()) - .orElse(dmaapUpdatePublisherConfiguration.dmaapProtocol())) - .dmaapTopicName( - Optional.ofNullable(updateProducerDmaapTopicName).filter(isEmpty.negate()) - .orElse(dmaapUpdatePublisherConfiguration.dmaapTopicName())) - .dmaapUserName( - Optional.ofNullable(updateProducerDmaapUserName).filter(isEmpty.negate()) - .orElse(dmaapUpdatePublisherConfiguration.dmaapUserName())) - .dmaapUserPassword( - Optional.ofNullable(updateProducerDmaapUserPassword).filter(isEmpty.negate()) - .orElse(dmaapUpdatePublisherConfiguration.dmaapUserPassword())) - .trustStorePath( - Optional.ofNullable(trustStorePath).filter(isEmpty.negate()) - .orElse(dmaapUpdatePublisherConfiguration.trustStorePath())) - .trustStorePasswordPath( - Optional.ofNullable(trustStorePasswordPath).filter(isEmpty.negate()) - .orElse(dmaapUpdatePublisherConfiguration.trustStorePasswordPath())) - .keyStorePath( - Optional.ofNullable(keyStorePath).filter(isEmpty.negate()) - .orElse(dmaapUpdatePublisherConfiguration.keyStorePath())) - .keyStorePasswordPath( - Optional.ofNullable(keyStorePasswordPath).filter(isEmpty.negate()) - .orElse(dmaapUpdatePublisherConfiguration.keyStorePasswordPath())) - .enableDmaapCertAuth( - Optional.ofNullable(enableDmaapCertAuth).filter(p -> !p.toString().isEmpty()) - .orElse(dmaapUpdatePublisherConfiguration.enableDmaapCertAuth())) - .build(); - } - - private boolean noFileConfiguration(Object object) { - return Objects.isNull(object); - } -} diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfiguration.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsConfiguration.java index 3d58f01e..3ff81e1f 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfiguration.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsConfiguration.java @@ -22,11 +22,9 @@ package org.onap.dcaegen2.services.prh.configuration; import com.google.gson.JsonObject; 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.cbs.client.api.CbsClientFactory; import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsRequests; import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.EnvProperties; -import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationClient; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration; import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext; @@ -49,8 +47,8 @@ import java.util.Optional; @EnableConfigurationProperties @EnableScheduling @Primary -public class ConsulConfiguration extends PrhAppConfig { - private static final Logger LOGGER = LoggerFactory.getLogger(ConsulConfiguration.class); +public class CbsConfiguration extends PrhAppConfig { + private static final Logger LOGGER = LoggerFactory.getLogger(CbsConfiguration.class); private AaiClientConfiguration aaiClientCBSConfiguration; private DmaapPublisherConfiguration dmaapPublisherCBSConfiguration; private DmaapConsumerConfiguration dmaapConsumerCBSConfiguration; @@ -83,11 +81,10 @@ public class ConsulConfiguration extends PrhAppConfig { private void parseCBSConfig(JsonObject jsonObject) { LOGGER.info("Received application configuration: {}", jsonObject); - ConsulConfigurationParser consulConfigurationParser = new ConsulConfigurationParser(jsonObject); + CbsContentParser consulConfigurationParser = new CbsContentParser(jsonObject); dmaapPublisherCBSConfiguration = consulConfigurationParser.getDmaapPublisherConfig(); dmaapUpdatePublisherCBSConfiguration = consulConfigurationParser.getDmaapUpdatePublisherConfig(); - aaiClientCBSConfiguration = ImmutableAaiClientConfiguration.copyOf(consulConfigurationParser.getAaiClientConfig()) - .withAaiHeaders(aaiClientConfiguration.aaiHeaders()); + aaiClientCBSConfiguration = consulConfigurationParser.getAaiClientConfig(); dmaapConsumerCBSConfiguration = consulConfigurationParser.getDmaapConsumerConfig(); } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParser.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java index b05c0324..e6bcda50 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParser.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java @@ -20,6 +20,8 @@ package org.onap.dcaegen2.services.prh.configuration; +import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; import com.google.gson.JsonObject; import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration; import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.ImmutableAaiClientConfiguration; @@ -28,10 +30,12 @@ import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPub import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapConsumerConfiguration; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapPublisherConfiguration; +import java.util.Map; + /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 8/21/18 */ -class ConsulConfigurationParser { +class CbsContentParser { private static final String SECURITY_TRUST_STORE_PATH = "security.trustStorePath"; private static final String SECURITY_TRUST_STORE_PASS_PATH = "security.trustStorePasswordPath"; private static final String SECURITY_KEY_STORE_PATH = "security.keyStorePath"; @@ -39,12 +43,13 @@ class ConsulConfigurationParser { private static final String CONFIG = "config"; private final JsonObject jsonObject; - ConsulConfigurationParser(JsonObject jsonObject) { + CbsContentParser(JsonObject jsonObject) { this.jsonObject = jsonObject.getAsJsonObject(CONFIG); } DmaapPublisherConfiguration getDmaapPublisherConfig() { return new ImmutableDmaapPublisherConfiguration.Builder() + .endpointUrl("http://dmaap-mr:2222/events/unauthenticated.PNF_READY") .dmaapTopicName(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapTopicName").getAsString()) .dmaapUserPassword(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapUserPassword").getAsString()) .dmaapPortNumber(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapPortNumber").getAsInt()) @@ -63,7 +68,8 @@ class ConsulConfigurationParser { DmaapPublisherConfiguration getDmaapUpdatePublisherConfig() { return new ImmutableDmaapPublisherConfiguration.Builder() - .dmaapTopicName(jsonObject.get("dmaap.dmaapUpdateProducerConfiguration.dmaapTopicName").getAsString()) + .endpointUrl("http://dmaap-mr:2222/events/unauthenticated.PNF_READY") + .dmaapTopicName(jsonObject.get("dmaap.dmaapUpdateProducerConfiguration.dmaapTopicName").getAsString()) .dmaapUserPassword(jsonObject.get("dmaap.dmaapUpdateProducerConfiguration.dmaapUserPassword").getAsString()) .dmaapPortNumber(jsonObject.get("dmaap.dmaapUpdateProducerConfiguration.dmaapPortNumber").getAsInt()) .dmaapProtocol(jsonObject.get("dmaap.dmaapUpdateProducerConfiguration.dmaapProtocol").getAsString()) @@ -88,7 +94,7 @@ class ConsulConfigurationParser { .aaiPnfPath(jsonObject.get("aai.aaiClientConfiguration.aaiPnfPath").getAsString()) .aaiServiceInstancePath(jsonObject.get("aai.aaiClientConfiguration.aaiServiceInstancePath").getAsString()) .aaiIgnoreSslCertificateErrors( - jsonObject.get("aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors").getAsBoolean()) + jsonObject.get("aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors").getAsBoolean()) .aaiUserPassword(jsonObject.get("aai.aaiClientConfiguration.aaiUserPassword").getAsString()) .aaiProtocol(jsonObject.get("aai.aaiClientConfiguration.aaiProtocol").getAsString()) .aaiBasePath(jsonObject.get("aai.aaiClientConfiguration.aaiBasePath").getAsString()) @@ -97,11 +103,14 @@ class ConsulConfigurationParser { .keyStorePath(jsonObject.get(SECURITY_KEY_STORE_PATH).getAsString()) .keyStorePasswordPath(jsonObject.get(SECURITY_KEY_STORE_PASS_PATH).getAsString()) .enableAaiCertAuth(jsonObject.get("security.enableAaiCertAuth").getAsBoolean()) + .aaiHeaders(new Gson().fromJson(jsonObject.get("aai.aaiClientConfiguration.aaiHeaders"), + new TypeToken<Map<String, String>>(){}.getType())) .build(); } DmaapConsumerConfiguration getDmaapConsumerConfig() { return new ImmutableDmaapConsumerConfiguration.Builder() + .endpointUrl("http://dmaap-mr:2222/events/unauthenticated.VES_PNFREG_OUTPUT") .timeoutMs(jsonObject.get("dmaap.dmaapConsumerConfiguration.timeoutMs").getAsInt()) .dmaapHostName(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapHostName").getAsString()) .dmaapUserName(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapUserName").getAsString()) diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java index 88f20205..6363356f 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java @@ -40,5 +40,4 @@ public interface Config { DmaapPublisherConfiguration getDmaapUpdatePublisherConfiguration(); - void initFileStreamReader(); } 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 108a3551..35895abb 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 @@ -56,8 +56,6 @@ public abstract class PrhAppConfig implements Config { private static final String AAI = "aai"; private static final String DMAAP = "dmaap"; private static final String AAI_CONFIG = "aaiClientConfiguration"; - private static final String DMAAP_PRODUCER = "dmaapProducerConfiguration"; - private static final String DMAAP_UPDATE_PRODUCER = "dmaapUpdateProducerConfiguration"; private static final String DMAAP_CONSUMER = "dmaapConsumerConfiguration"; private static final String SECURITY = "security"; @@ -69,9 +67,6 @@ public abstract class PrhAppConfig implements Config { DmaapPublisherConfiguration dmaapUpdatePublisherConfiguration; - @Value("classpath:prh_endpoints.json") - private Resource prhEndpoints; - @Value("classpath:git_info.json") private Resource gitInfo; @@ -105,26 +100,6 @@ public abstract class PrhAppConfig implements Config { return dmaapUpdatePublisherConfiguration; } - @Override - public void initFileStreamReader() { - GsonBuilder gsonBuilder = new GsonBuilder(); - ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory); - JsonParser parser = new JsonParser(); - - try (InputStream inputStream = prhEndpoints.getInputStream()) { - JsonElement rootElement = getJsonElement(parser, inputStream); - if (rootElement.isJsonObject()) { - deserializeAaiConfiguration(gsonBuilder, rootElement); - deserializeDmaapConsumerConfiguration(gsonBuilder, rootElement); - dmaapPublisherConfiguration = - deserializeDmaapPublisherConfiguration(DMAAP_PRODUCER, gsonBuilder, rootElement); - dmaapUpdatePublisherConfiguration = - deserializeDmaapPublisherConfiguration(DMAAP_UPDATE_PRODUCER, gsonBuilder, rootElement); - } - } catch (IOException e) { - LOGGER.warn("Failed to load/parse file", e); - } - } private DmaapPublisherConfiguration deserializeDmaapPublisherConfiguration( final String dmaapProducerType, @@ -171,9 +146,4 @@ public abstract class PrhAppConfig implements Config { return null; } } - - @VisibleForTesting - void setPrhEndpoints(Resource prhEndpoints) { - this.prhEndpoints = prhEndpoints; - } } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java index eb5b51a1..02691446 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java @@ -75,7 +75,6 @@ public class BbsActionsTaskImpl implements BbsActionsTask { } public Mono<ConsumerDmaapModel> execute(ConsumerDmaapModel consumerDmaapModel) { - config.initFileStreamReader(); JsonObject additionalFields = consumerDmaapModel.getAdditionalFields(); if (additionalFields == null || !additionalFields.has(ATTACHMENT_POINT)) { diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java index e3ea8962..3a630a40 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java @@ -33,8 +33,6 @@ import reactor.core.publisher.Flux; */ interface DmaapConsumerTask { - void initConfigs(); - Flux<ConsumerDmaapModel> execute(String object) throws SSLException; DMaaPConsumerReactiveHttpClient resolveClient() throws SSLException; diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java index 0d71477c..d3086cbe 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java @@ -63,11 +63,6 @@ public class DmaapConsumerTaskImpl implements DmaapConsumerTask { } @Override - public void initConfigs() { - config.initFileStreamReader(); - } - - @Override public Flux<ConsumerDmaapModel> execute(String object) throws SSLException { DMaaPConsumerReactiveHttpClient dmaaPConsumerReactiveHttpClient = resolveClient(); LOGGER.debug("Method called with arg {}", object); 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 aae5bc77..72ec0cac 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 @@ -48,7 +48,7 @@ import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.RESPONSE @Component public class ScheduledTasks { - private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ScheduledTasks.class); private static final Marker INVOKE = MarkerFactory.getMarker("INVOKE"); private final DmaapConsumerTask dmaapConsumerTask; private final DmaapPublisherTask dmaapReadyProducerTask; @@ -100,36 +100,36 @@ public class ScheduledTasks { public void scheduleMainPrhEventTask() { MdcVariables.setMdcContextMap(mdcContextMap); try { - logger.trace("Execution of tasks was registered"); + LOGGER.trace("Execution of tasks was registered"); CountDownLatch mainCountDownLatch = new CountDownLatch(1); consumeFromDMaaPMessage() .doOnError(DmaapEmptyResponseException.class, error -> - logger.warn("Nothing to consume from DMaaP") + LOGGER.warn("Nothing to consume from DMaaP") ) .flatMap(this::queryAaiForConfiguration) .flatMap(this::publishToAaiConfiguration) .doOnError(exception -> - logger.warn("AAIProducerTask exception has been registered: ", exception)) + LOGGER.warn("AAIProducerTask exception has been registered: ", exception)) .onErrorResume(resumePrhPredicate(), exception -> Mono.empty()) .flatMap(this::processAdditionalFields) .doOnError(exception -> - logger.warn("BBSActionsTask exception has been registered: ", exception)) + LOGGER.warn("BBSActionsTask exception has been registered: ", exception)) .flatMap(this::publishToDmaapConfigurationWithApache) .doOnError(exception -> - logger.warn("DMaaPProducerTask exception has been registered: ", exception)) + LOGGER.warn("DMaaPProducerTask exception has been registered: ", exception)) .onErrorResume(resumePrhPredicate(), exception -> Mono.empty()) .doOnTerminate(mainCountDownLatch::countDown) .subscribe(this::onSuccess, this::onError, this::onComplete); mainCountDownLatch.await(); } catch (InterruptedException e) { - logger.warn("Interruption problem on countDownLatch ", e); + LOGGER.warn("Interruption problem on countDownLatch ", e); Thread.currentThread().interrupt(); } } private void onComplete() { - logger.info("PRH tasks have been completed"); + LOGGER.info("PRH tasks have been completed"); } /** @@ -139,7 +139,7 @@ public class ScheduledTasks { private void onSuccess(HttpClientResponse response) { String statusCode = Integer.toString(response.status().code()); MDC.put(RESPONSE_CODE, statusCode); - logger.info("Prh consumed tasks successfully. HTTP Response code from DMaaPProducer {}", + LOGGER.info("Prh consumed tasks successfully. HTTP Response code from DMaaPProducer {}", statusCode); MDC.remove(RESPONSE_CODE); } @@ -147,7 +147,7 @@ public class ScheduledTasks { private void onSuccess(HttpResponse response) { String statusCode = Integer.toString(response.getStatusLine().getStatusCode()); MDC.put(RESPONSE_CODE, statusCode); - logger.info("Prh consumed tasks successfully. HTTP Response code from DMaaPProducer {}", + LOGGER.info("Prh consumed tasks successfully. HTTP Response code from DMaaPProducer {}", statusCode); MDC.remove(RESPONSE_CODE); } @@ -155,7 +155,7 @@ public class ScheduledTasks { private void onError(Throwable throwable) { if (!(throwable instanceof DmaapEmptyResponseException)) { - logger.warn("Chain of tasks have been aborted due to errors in PRH workflow", throwable); + LOGGER.warn("Chain of tasks have been aborted due to errors in PRH workflow", throwable); } } @@ -163,8 +163,7 @@ public class ScheduledTasks { return Flux.defer(() -> { MdcVariables.setMdcContextMap(mdcContextMap); MDC.put(INSTANCE_UUID, UUID.randomUUID().toString()); - logger.info(INVOKE, "Init configs"); - dmaapConsumerTask.initConfigs(); + LOGGER.info(INVOKE, "Init configs"); return consumeFromDMaaP(); }); } @@ -197,7 +196,7 @@ public class ScheduledTasks { private Mono<State> processAdditionalFields(final State state) { if (state.ActivationStatus) { - logger.debug("Re-registration - Logical links won't be updated."); + LOGGER.debug("Re-registration - Logical links won't be updated."); return Mono.just(state); } @@ -213,7 +212,7 @@ public class ScheduledTasks { publishToDmaapConfiguration(final State state) { try { if (state.ActivationStatus) { - logger.debug("Re-registration - Using PNF_UPDATE DMaaP topic."); + LOGGER.debug("Re-registration - Using PNF_UPDATE DMaaP topic."); return dmaapUpdateProducerTask.execute(state.DmaapModel); } @@ -227,7 +226,7 @@ public class ScheduledTasks { publishToDmaapConfigurationWithApache(final State state) { try { if (state.ActivationStatus) { - logger.debug("Re-registration - Using PNF_UPDATE DMaaP topic."); + LOGGER.debug("Re-registration - Using PNF_UPDATE DMaaP topic."); return dmaapUpdateProducerTask.executeWithApache(state.DmaapModel); } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java index e20e25d8..e9c18109 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java @@ -28,7 +28,7 @@ import java.util.List; import java.util.concurrent.ScheduledFuture; import javax.annotation.PostConstruct; -import org.onap.dcaegen2.services.prh.configuration.ConsulConfiguration; +import org.onap.dcaegen2.services.prh.configuration.CbsConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.Marker; @@ -57,15 +57,15 @@ public class ScheduledTasksRunner { private final TaskScheduler taskScheduler; private final ScheduledTasks scheduledTask; - private final ConsulConfiguration consulConfiguration; + private final CbsConfiguration cbsConfiguration; @Autowired public ScheduledTasksRunner(TaskScheduler taskScheduler, ScheduledTasks scheduledTask, - ConsulConfiguration consulConfiguration) { + CbsConfiguration cbsConfiguration) { this.taskScheduler = taskScheduler; this.scheduledTask = scheduledTask; - this.consulConfiguration = consulConfiguration; + this.cbsConfiguration = cbsConfiguration; } /** @@ -94,7 +94,7 @@ public class ScheduledTasksRunner { LOGGER.info(ENTRY, "Start scheduling PRH workflow"); if (scheduledPrhTaskFutureList.isEmpty()) { scheduledPrhTaskFutureList.add(taskScheduler - .scheduleAtFixedRate(consulConfiguration::runTask, Instant.now(), + .scheduleAtFixedRate(cbsConfiguration::runTask, Instant.now(), Duration.ofMinutes(SCHEDULING_REQUEST_FOR_CONFIGURATION_DELAY))); scheduledPrhTaskFutureList.add(taskScheduler .scheduleWithFixedDelay(scheduledTask::scheduleMainPrhEventTask, diff --git a/prh-app-server/src/main/resources/consul_config.json b/prh-app-server/src/main/resources/consul_config.json index 7cefd641..2ec0d57c 100644 --- a/prh-app-server/src/main/resources/consul_config.json +++ b/prh-app-server/src/main/resources/consul_config.json @@ -1,5 +1,5 @@ { - "consulHost": "10.42.111.9", + "consulHost": "10.42.111.11", "cbsName": "cbs", "appName": "dcae-prh" }
\ No newline at end of file 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 b09d039a..9dca398a 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 @@ -28,6 +28,7 @@ import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.Immutabl public class TestAppConfiguration { public static ImmutableDmaapConsumerConfiguration createDefaultDmaapConsumerConfiguration() { return new ImmutableDmaapConsumerConfiguration.Builder() + .endpointUrl("http://dmaap-mr:2222/events/unauthenticated.VES_PNFREG_OUTPUT") .consumerGroup("OpenDCAE-c12") .consumerId("c12") .dmaapContentType("application/json") @@ -49,6 +50,7 @@ public class TestAppConfiguration { public static ImmutableDmaapPublisherConfiguration createDefaultDmaapPublisherConfiguration() { return new ImmutableDmaapPublisherConfiguration.Builder() + .endpointUrl("http://dmaap-mr:2222/events/unauthenticated.PNF_READY") .dmaapContentType("application/json") .dmaapHostName("message-router.onap.svc.cluster.local") .dmaapPortNumber(3904) @@ -81,6 +83,11 @@ public class TestAppConfiguration { .keyStorePath("/opt/app/prh/local/org.onap.prh.p12") .keyStorePasswordPath("change_it") .enableAaiCertAuth(false) + .putAaiHeaders("X-FromAppId","prh") + .putAaiHeaders("X-TransactionId","9999") + .putAaiHeaders("Accept","application/json") + .putAaiHeaders("Real-Time","true") + .putAaiHeaders("Authorization","Basic QUFJOkFBSQ==") .build(); } }
\ No newline at end of file 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 3c746940..8a2a498f 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 @@ -47,7 +47,7 @@ class ConsulConfigurationParserTest { TestAppConfiguration.createDefaultDmaapConsumerConfiguration(); private final ImmutableDmaapPublisherConfiguration correctDmaapPublisherConfig = TestAppConfiguration.createDefaultDmaapPublisherConfiguration(); - private final ConsulConfigurationParser consulConfigurationParser = new ConsulConfigurationParser( + private final CbsContentParser consulConfigurationParser = new CbsContentParser( new Gson().fromJson(correctJson, JsonObject.class)); ConsulConfigurationParserTest() throws Exception { diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java deleted file mode 100644 index 249fccc3..00000000 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018-2019 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.configuration; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.dcaegen2.services.prh.integration.junit5.mockito.MockitoExtension; -import org.springframework.core.io.InputStreamResource; -import org.springframework.core.io.Resource; - -import java.io.*; -import java.nio.file.Paths; - -import static java.lang.ClassLoader.getSystemResource; -import static java.nio.file.Files.readAllBytes; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18 - */ -@ExtendWith({ MockitoExtension.class }) -class PrhAppConfigTest { - - private static final String CORRECT_CONFIG_FILE = "correct_config.json"; - private static final String INCORRECT_CONFIG_FILE = "incorrect_config.json"; - private static final String NOT_JSON_OBJECT_FILE = "not_json_object.json"; - private AppConfig appConfig; - - @BeforeEach - void setUp() { - appConfig = new AppConfig(); - } - - @Test - void whenTheConfigurationFits() throws Exception { - InputStream inputStream = createInputStream(CORRECT_CONFIG_FILE); - appConfig.setPrhEndpoints(new InputStreamResource(inputStream)); - appConfig.initFileStreamReader(); - - assertNotNull(appConfig.getDmaapConsumerConfiguration()); - assertNotNull(appConfig.getDmaapPublisherConfiguration()); - assertNotNull(appConfig.getAaiClientConfiguration()); - } - - @Test - void whenFileDoesNotExist() throws Exception { - InputStream inputStream = createInputStream(CORRECT_CONFIG_FILE); - Resource resource = spy(new InputStreamResource(inputStream)); - when(resource.getInputStream()).thenThrow(new IOException()); - appConfig.setPrhEndpoints(resource); - appConfig.initFileStreamReader(); - - assertNull(appConfig.getAaiClientConfiguration()); - assertNull(appConfig.getDmaapConsumerConfiguration()); - assertNull(appConfig.getDmaapPublisherConfiguration()); - } - - @Test - void whenFileExistsButDmaapPublisherJsonConfigurationIsIncorrect() throws Exception { - InputStream inputStream = createInputStream(INCORRECT_CONFIG_FILE); - appConfig.setPrhEndpoints(new InputStreamResource(inputStream)); - appConfig.initFileStreamReader(); - - assertNotNull(appConfig.getAaiClientConfiguration()); - assertNotNull(appConfig.getDmaapConsumerConfiguration()); - assertNull(appConfig.getDmaapPublisherConfiguration()); - } - - @Test - void whenRootElementIsNotAJsonObject() throws Exception { - InputStream inputStream = createInputStream(NOT_JSON_OBJECT_FILE); - appConfig.setPrhEndpoints(new InputStreamResource(inputStream)); - appConfig.initFileStreamReader(); - - - assertNull(appConfig.getAaiClientConfiguration()); - assertNull(appConfig.getDmaapConsumerConfiguration()); - assertNull(appConfig.getDmaapPublisherConfiguration()); - } - - private InputStream createInputStream(String jsonFile) throws Exception { - return new ByteArrayInputStream(readAllBytes(Paths.get(getSystemResource(jsonFile).toURI()))); - } -} diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImplTest.java index 1160f77e..0077a6a6 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImplTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImplTest.java @@ -27,7 +27,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.onap.dcaegen2.services.prh.TestAppConfiguration; -import org.onap.dcaegen2.services.prh.configuration.AppConfig; +import org.onap.dcaegen2.services.prh.configuration.CbsConfiguration; import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException; import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel; import org.onap.dcaegen2.services.prh.model.ImmutableConsumerDmaapModel; @@ -51,7 +51,7 @@ class AaiProducerTaskImplTest { private AaiProducerTaskImpl aaiProducerTask; private AaiClientConfiguration aaiClientConfiguration; private AaiHttpPatchClient aaiReactiveHttpPatchClient; - private AppConfig appConfig; + private CbsConfiguration cbsConfiguration; private HttpResponse clientResponse; @BeforeEach @@ -70,14 +70,14 @@ class AaiProducerTaskImplTest { .swVersion("v4.5.0.1") .additionalFields(new JsonObject()) .build(); - appConfig = mock(AppConfig.class); + cbsConfiguration = mock(CbsConfiguration.class); } @Test void whenPassedObjectDoesntFit_ThrowsPrhTaskException() { //given/when/ - when(appConfig.getAaiClientConfiguration()).thenReturn(aaiClientConfiguration); + when(cbsConfiguration.getAaiClientConfiguration()).thenReturn(aaiClientConfiguration); aaiProducerTask = new AaiProducerTaskImpl(aaiReactiveHttpPatchClient); Executable executableCode = () -> aaiProducerTask.execute(null); @@ -117,7 +117,7 @@ class AaiProducerTaskImplTest { aaiReactiveHttpPatchClient = mock(AaiHttpPatchClient.class); when(aaiReactiveHttpPatchClient.getAaiResponse(any())) .thenReturn(clientResponseMono); - when(appConfig.getAaiClientConfiguration()).thenReturn(aaiClientConfiguration); + when(cbsConfiguration.getAaiClientConfiguration()).thenReturn(aaiClientConfiguration); aaiProducerTask = spy(new AaiProducerTaskImpl(aaiReactiveHttpPatchClient)); } }
\ No newline at end of file diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiPublisherTaskSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiPublisherTaskSpy.java index ae770fc6..18e1a27a 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiPublisherTaskSpy.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiPublisherTaskSpy.java @@ -25,7 +25,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import javax.net.ssl.SSLException; -import org.onap.dcaegen2.services.prh.configuration.AppConfig; + +import org.onap.dcaegen2.services.prh.configuration.CbsConfiguration; import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel; import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration; import org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.http.patch.AaiHttpPatchClient; @@ -49,9 +50,9 @@ public class AaiPublisherTaskSpy { @Bean @Primary public AaiProducerTask registerSimpleAaiPublisherTask() throws SSLException { - AppConfig appConfig = spy(AppConfig.class); + CbsConfiguration cbsConfiguration = spy(CbsConfiguration.class); ConsumerDmaapModel consumerDmaapModel = spy(ConsumerDmaapModel.class); - doReturn(mock(AaiClientConfiguration.class)).when(appConfig).getAaiClientConfiguration(); + doReturn(mock(AaiClientConfiguration.class)).when(cbsConfiguration).getAaiClientConfiguration(); AaiHttpPatchClient aaiReactiveHttpPatchClient = mock(AaiHttpPatchClient.class); AaiProducerTaskImpl aaiProducerTask = spy(new AaiProducerTaskImpl(aaiReactiveHttpPatchClient)); diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java index 341cb096..5edf15a8 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java @@ -40,7 +40,7 @@ import java.io.InputStreamReader; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.onap.dcaegen2.services.prh.TestAppConfiguration; -import org.onap.dcaegen2.services.prh.configuration.AppConfig; +import org.onap.dcaegen2.services.prh.configuration.CbsConfiguration; import org.onap.dcaegen2.services.prh.exceptions.AaiFailureException; import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel; import org.onap.dcaegen2.services.prh.model.ImmutableConsumerDmaapModel; @@ -57,18 +57,19 @@ class BbsActionsTaskTest { private static final String CORRECT_LOGICAL_LINK_JSON = "bbs_action/correct_logical_link.json"; public static final String AAI_URL = "https://aai.onap.svc.cluster.local:8443/aai/v12/network/logical-links/logical-link/some-link"; + private CbsConfiguration cbsConfiguration = mock(CbsConfiguration.class); + private AaiClientConfiguration aaiClientConfiguration = TestAppConfiguration.createDefaultAaiClientConfiguration(); - private AppConfig appConfig = mock(AppConfig.class); private RxHttpClient httpClient = mock(RxHttpClient.class); @Test void whenPassedObjectDoesntHaveAdditionalFields_ReturnPayloadTransparently() { // given - given(appConfig.getAaiClientConfiguration()).willReturn(aaiClientConfiguration); + given(cbsConfiguration.getAaiClientConfiguration()).willReturn(aaiClientConfiguration); ConsumerDmaapModel consumerDmaapModel = buildConsumerDmaapModel(null); // when - ConsumerDmaapModel result = new BbsActionsTaskImpl(appConfig, httpClient).execute(consumerDmaapModel).block(); + ConsumerDmaapModel result = new BbsActionsTaskImpl(cbsConfiguration, httpClient).execute(consumerDmaapModel).block(); // then verifyZeroInteractions(httpClient); @@ -78,14 +79,14 @@ class BbsActionsTaskTest { @Test void whenPassedObjectHasEmptyLogicalLink_ReturnPayloadTransparently() { // given - given(appConfig.getAaiClientConfiguration()).willReturn(aaiClientConfiguration); + given(cbsConfiguration.getAaiClientConfiguration()).willReturn(aaiClientConfiguration); JsonObject additionalFields = new JsonObject(); additionalFields.addProperty("attachmentPoint", ""); ConsumerDmaapModel consumerDmaapModel = buildConsumerDmaapModel(additionalFields); // when - ConsumerDmaapModel result = new BbsActionsTaskImpl(appConfig, httpClient).execute(consumerDmaapModel).block(); + ConsumerDmaapModel result = new BbsActionsTaskImpl(cbsConfiguration, httpClient).execute(consumerDmaapModel).block(); // then verifyZeroInteractions(httpClient); @@ -95,7 +96,7 @@ class BbsActionsTaskTest { @Test void whenPassedObjectHasLogicalLink_createLogicalLink_and_associateWithPnf_and_ReturnPayloadTransparently() { // given - given(appConfig.getAaiClientConfiguration()).willReturn(aaiClientConfiguration); + given(cbsConfiguration.getAaiClientConfiguration()).willReturn(aaiClientConfiguration); JsonObject additionalFields = new JsonObject(); additionalFields.addProperty("attachmentPoint", "some-link"); @@ -104,7 +105,7 @@ class BbsActionsTaskTest { given(httpClient.call(any())).willReturn(Mono.just(buildAaiResponse(HttpResponseStatus.OK))); // when - Mono<ConsumerDmaapModel> response = new BbsActionsTaskImpl(appConfig, httpClient).execute(consumerDmaapModel); + Mono<ConsumerDmaapModel> response = new BbsActionsTaskImpl(cbsConfiguration, httpClient).execute(consumerDmaapModel); // then assertEquals(consumerDmaapModel, response.block()); @@ -114,7 +115,7 @@ class BbsActionsTaskTest { @Test void whenPassedObjectHasLogicalLink_butAaiQueryFails_returnError() { // given - given(appConfig.getAaiClientConfiguration()).willReturn(aaiClientConfiguration); + given(cbsConfiguration.getAaiClientConfiguration()).willReturn(aaiClientConfiguration); JsonObject additionalFields = new JsonObject(); additionalFields.addProperty("attachmentPoint", "some-link"); @@ -123,7 +124,7 @@ class BbsActionsTaskTest { given(httpClient.call(any())).willReturn(Mono.just(buildAaiResponse(HttpResponseStatus.INTERNAL_SERVER_ERROR))); // when - Mono<ConsumerDmaapModel> response = new BbsActionsTaskImpl(appConfig, httpClient).execute(consumerDmaapModel); + Mono<ConsumerDmaapModel> response = new BbsActionsTaskImpl(cbsConfiguration, httpClient).execute(consumerDmaapModel); // then ArgumentCaptor<HttpRequest> captor = ArgumentCaptor.forClass(HttpRequest.class); diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java index 9b34ef4c..9afa7671 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java @@ -34,7 +34,7 @@ import com.google.gson.JsonParser; import java.util.Optional; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.prh.configuration.AppConfig; +import org.onap.dcaegen2.services.prh.configuration.CbsConfiguration; import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel; import org.onap.dcaegen2.services.prh.model.ImmutableConsumerDmaapModel; import org.onap.dcaegen2.services.prh.service.DmaapConsumerJsonParser; @@ -53,13 +53,14 @@ class DmaapConsumerTaskImplTest { private static ConsumerDmaapModel consumerDmaapModel; private static DmaapConsumerTaskImpl dmaapConsumerTask; private static DMaaPConsumerReactiveHttpClient dMaaPConsumerReactiveHttpClient; - private static AppConfig appConfig; private static DmaapConsumerConfiguration dmaapConsumerConfiguration; private static String message; private static String messageContentEmpty; private static JsonArray jsonArray; private static JsonArray jsonArrayWrongContent; + private static CbsConfiguration cbsConfiguration; + @BeforeAll static void setUp() { dmaapConsumerConfiguration = createDefaultDmaapConsumerConfiguration(); @@ -82,7 +83,7 @@ class DmaapConsumerTaskImplTest { .swVersion("v4.5.0.1") .additionalFields(jsonObject) .build(); - appConfig = mock(AppConfig.class); + cbsConfiguration = mock(CbsConfiguration.class); message = "[{\"event\": {" + "\"commonEventHeader\": { " @@ -135,22 +136,15 @@ class DmaapConsumerTaskImplTest { assertEquals(consumerDmaapModel, response.blockFirst()); } - @Test - void whenInitConfigs_initStreamReader() { - //when - dmaapConsumerTask.initConfigs(); - //then - verify(appConfig).initFileStreamReader(); - } private void prepareMocksForDmaapConsumer(Optional<JsonArray> message) throws Exception { dMaaPConsumerReactiveHttpClient = mock(DMaaPConsumerReactiveHttpClient.class); when(dMaaPConsumerReactiveHttpClient.getDMaaPConsumerResponse(Optional.empty())) .thenReturn(Mono.just(message.get())); - when(appConfig.getDmaapConsumerConfiguration()).thenReturn(dmaapConsumerConfiguration); + when(cbsConfiguration.getDmaapConsumerConfiguration()).thenReturn(dmaapConsumerConfiguration); ConsumerReactiveHttpClientFactory httpClientFactory = mock(ConsumerReactiveHttpClientFactory.class); doReturn(dMaaPConsumerReactiveHttpClient).when(httpClientFactory).create(dmaapConsumerConfiguration); - dmaapConsumerTask = new DmaapConsumerTaskImpl(appConfig, new DmaapConsumerJsonParser(), httpClientFactory); + dmaapConsumerTask = new DmaapConsumerTaskImpl(cbsConfiguration, new DmaapConsumerJsonParser(), httpClientFactory); } }
\ No newline at end of file diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskSpy.java index cb31c86b..594575e5 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskSpy.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskSpy.java @@ -25,7 +25,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import javax.net.ssl.SSLException; -import org.onap.dcaegen2.services.prh.configuration.AppConfig; + +import org.onap.dcaegen2.services.prh.configuration.CbsConfiguration; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.consumer.DMaaPConsumerReactiveHttpClient; import org.springframework.context.annotation.Bean; @@ -47,9 +48,9 @@ public class DmaapConsumerTaskSpy { @Bean @Primary public DmaapConsumerTask registerSimpleDmaapConsumerTask() throws SSLException { - AppConfig appConfig = spy(AppConfig.class); - doReturn(mock(DmaapConsumerConfiguration.class)).when(appConfig).getDmaapConsumerConfiguration(); - DmaapConsumerTaskImpl dmaapConsumerTask = spy(new DmaapConsumerTaskImpl(appConfig)); + CbsConfiguration cbsConfiguration = spy(CbsConfiguration.class); + doReturn(mock(DmaapConsumerConfiguration.class)).when(cbsConfiguration).getDmaapConsumerConfiguration(); + DmaapConsumerTaskImpl dmaapConsumerTask = spy(new DmaapConsumerTaskImpl(cbsConfiguration)); DMaaPConsumerReactiveHttpClient dmaapConsumerReactiveHttpClient = mock( DMaaPConsumerReactiveHttpClient.class); doReturn(dmaapConsumerReactiveHttpClient).when(dmaapConsumerTask).resolveClient(); diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapProducerTaskSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapProducerTaskSpy.java index 08b10d98..77028a34 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapProducerTaskSpy.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapProducerTaskSpy.java @@ -25,7 +25,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import javax.net.ssl.SSLException; -import org.onap.dcaegen2.services.prh.configuration.AppConfig; +import org.onap.dcaegen2.services.prh.configuration.CbsConfiguration; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.producer.DMaaPPublisherReactiveHttpClient; import org.springframework.context.annotation.Bean; @@ -48,9 +48,9 @@ public class DmaapProducerTaskSpy { @Bean @Primary public DmaapPublisherTask registerSimpleDmaapPublisherTask() throws SSLException { - final AppConfig appConfig = spy(AppConfig.class); - final Supplier<DmaapPublisherConfiguration> configSupplier = () -> appConfig.getDmaapPublisherConfiguration(); - doReturn(mock(DmaapPublisherConfiguration.class)).when(appConfig).getDmaapPublisherConfiguration(); + final CbsConfiguration cbsConfiguration = spy(CbsConfiguration.class); + final Supplier<DmaapPublisherConfiguration> configSupplier = () -> cbsConfiguration.getDmaapPublisherConfiguration(); + doReturn(mock(DmaapPublisherConfiguration.class)).when(cbsConfiguration).getDmaapPublisherConfiguration(); final DmaapPublisherTaskImpl dmaapPublisherTask = spy(new DmaapPublisherTaskImpl(configSupplier)); final DMaaPPublisherReactiveHttpClient extendedDmaapProducerHttpClient = mock( DMaaPPublisherReactiveHttpClient.class); 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 6bcf6737..fb4a50ea 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 @@ -24,7 +24,7 @@ import io.netty.handler.codec.http.HttpResponseStatus; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; -import org.onap.dcaegen2.services.prh.configuration.AppConfig; +import org.onap.dcaegen2.services.prh.configuration.CbsConfiguration; import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException; import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException; import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel; @@ -54,7 +54,7 @@ class DmaapPublisherTaskImplTest { private static ConsumerDmaapModel consumerDmaapModel; private static DmaapPublisherTaskImpl dmaapPublisherTask; private static DMaaPPublisherReactiveHttpClient dMaaPPublisherReactiveHttpClient; - private static AppConfig appConfig; + private static CbsConfiguration cbsConfiguration; private static DmaapPublisherConfiguration dmaapPublisherConfiguration; private Optional<RequestDiagnosticContext> requestDiagnosticContextOptionalMock; private DmaapModel dmaapModel; @@ -65,15 +65,15 @@ class DmaapPublisherTaskImplTest { public void beforeEach() throws SSLException { dmaapPublisherConfiguration = createDefaultDmaapPublisherConfiguration(); consumerDmaapModel = mock(ConsumerDmaapModel.class); - appConfig = mock(AppConfig.class); + cbsConfiguration = mock(CbsConfiguration.class); requestDiagnosticContextOptionalMock = Optional.empty(); dmaapModel = mock(DmaapModel.class); dMaaPPublisherReactiveHttpClient = mock(DMaaPPublisherReactiveHttpClient.class); publisherReactiveHttpClientFactory = mock(PublisherReactiveHttpClientFactory.class); - when(appConfig.getDmaapPublisherConfiguration()).thenReturn(dmaapPublisherConfiguration); + when(cbsConfiguration.getDmaapPublisherConfiguration()).thenReturn(dmaapPublisherConfiguration); when(publisherReactiveHttpClientFactory.create(dmaapPublisherConfiguration)) .thenReturn(dMaaPPublisherReactiveHttpClient); - configSupplier = () -> appConfig.getDmaapPublisherConfiguration(); + configSupplier = () -> cbsConfiguration.getDmaapPublisherConfiguration(); } @Test diff --git a/prh-app-server/src/test/resources/correct_config.json b/prh-app-server/src/test/resources/correct_config.json index 9ef75122..ec3ebee4 100644 --- a/prh-app-server/src/test/resources/correct_config.json +++ b/prh-app-server/src/test/resources/correct_config.json @@ -1,67 +1,74 @@ { - "configs": { - "aai": { - "aaiClientConfiguration": { - "pnfUrl": "https://localhost:8080/aai/v11/network/pnfs/pnf", - "aaiHost": "localhost", - "aaiPort": 8080, - "aaiIgnoreSslCertificateErrors": true, - "aaiProtocol": "https", - "aaiUserName": "admin", - "aaiUserPassword": "admin", - "aaiBasePath": "/aai/v11", - "aaiPnfPath": "/network/pnfs/pnf", - "aaiServiceInstancePath": "/business/customers/customer/${customer}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}", - "aaiHeaders": { - "X-FromAppId": "prh", - "X-TransactionId": "9999", - "Accept": "application/json", - "Real-Time": "true", - "Content-Type": "application/merge-patch+json", - "Authorization": "Basic QUFJOkFBSQ==" - } - } + "config":{ + "dmaap.dmaapConsumerConfiguration.dmaapUrl":"http://dmaap-mr:2222/events/unauthenticated.VES_PNFREG_OUTPUT", + "dmaap.dmaapConsumerConfiguration.dmaapHostName":"dmaap-mr", + "dmaap.dmaapConsumerConfiguration.dmaapPortNumber":2223, + "dmaap.dmaapConsumerConfiguration.dmaapTopicName":"events/unauthenticated.VES_PNFREG_OUTPUT", + "dmaap.dmaapConsumerConfiguration.dmaapProtocol":"http", + "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.dmaapConsumerConfiguration.messageLimit":-1, + "dmaap.dmaapProducerConfiguration.dmaapUrl":"http://dmaap-mr:2222/events/unauthenticated.PNF_READY", + "dmaap.dmaapProducerConfiguration.dmaapHostName":"dmaap-mr", + "dmaap.dmaapProducerConfiguration.dmaapPortNumber":2223, + "dmaap.dmaapProducerConfiguration.dmaapTopicName":"events/unauthenticated.PNF_READY", + "dmaap.dmaapProducerConfiguration.dmaapProtocol":"http", + "dmaap.dmaapProducerConfiguration.dmaapUserName":"admin", + "dmaap.dmaapProducerConfiguration.dmaapUserPassword":"admin", + "dmaap.dmaapProducerConfiguration.dmaapContentType":"application/json", + "dmaap.dmaapUpdateProducerConfiguration.dmaapUrl":"http://dmaap-mr:2222/events/unauthenticated.PNF_UPDATE", + "dmaap.dmaapUpdateProducerConfiguration.dmaapHostName":"dmaap-mr", + "dmaap.dmaapUpdateProducerConfiguration.dmaapPortNumber":2223, + "dmaap.dmaapUpdateProducerConfiguration.dmaapTopicName":"events/unauthenticated.PNF_UPDATE", + "dmaap.dmaapUpdateProducerConfiguration.dmaapProtocol":"http", + "dmaap.dmaapUpdateProducerConfiguration.dmaapUserName":"admin", + "dmaap.dmaapUpdateProducerConfiguration.dmaapUserPassword":"admin", + "dmaap.dmaapUpdateProducerConfiguration.dmaapContentType":"application/json", + "aai.aaiClientConfiguration.pnfUrl":"https://aai:3333/aai/v12/network/pnfs/pnf", + "aai.aaiClientConfiguration.aaiHost":"aai", + "aai.aaiClientConfiguration.aaiHostPortNumber":3334, + "aai.aaiClientConfiguration.aaiProtocol":"https", + "aai.aaiClientConfiguration.aaiUserName":"DCAE", + "aai.aaiClientConfiguration.aaiUserPassword":"DCAE", + "aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors":true, + "aai.aaiClientConfiguration.aaiBasePath":"/aai/v12", + "aai.aaiClientConfiguration.aaiPnfPath":"/network/pnfs/pnf", + "aai.aaiClientConfiguration.aaiServiceInstancePath":"/business/customers/customer//service-subscriptions/service-subscription//service-instances/service-instance/", + "aai.aaiClientConfiguration.aaiHeaders":{ + "X-FromAppId":"prh", + "X-TransactionId":"9999", + "Accept":"application/json", + "Real-Time":"true", + "Authorization":"Basic QUFJOkFBSQ==" }, - "dmaap": { - "dmaapConsumerConfiguration": { - "consumerGroup": "other", - "consumerId": "1", - "dmaapContentType": "application/json", - "dmaapHostName": "localhost", - "dmaapPortNumber": 2222, - "dmaapProtocol": "http", - "dmaapTopicName": "temp", - "dmaapUserName": "admin", - "dmaapUserPassword": "admin", - "messageLimit": 1000, - "timeoutMs": 1000 - }, - "dmaapProducerConfiguration": { - "dmaapContentType": "application/json", - "dmaapHostName": "localhost", - "dmaapPortNumber": 2223, - "dmaapProtocol": "http", - "dmaapTopicName": "temp", - "dmaapUserName": "admin", - "dmaapUserPassword": "admin" + "security.trustStorePath":"change it", + "security.trustStorePasswordPath":"change it", + "security.keyStorePath":"change it", + "security.keyStorePasswordPath":"change it", + "security.enableAaiCertAuth":false, + "security.enableDmaapCertAuth":false, + "streams_publishes":{ + "pnf-update":{ + "dmaap_info":{ + "topic_url":"http://dmaap-mr:2222/events/unauthenticated.PNF_UPDATE" + } }, - "dmaapUpdateProducerConfiguration": { - "dmaapContentType": "application/json", - "dmaapHostName": "localhost", - "dmaapPortNumber": 2223, - "dmaapProtocol": "http", - "dmaapTopicName": "temp2", - "dmaapUserName": "admin", - "dmaapUserPassword": "admin" + "pnf-ready":{ + "dmaap_info":{ + "topic_url":"http://dmaap-mr:2222/events/unauthenticated.PNF_READY" + } } }, - "security": { - "trustStorePath": "/opt/app/prh/local/org.onap.prh.trust.jks", - "trustStorePasswordPath": "change it", - "keyStorePath": "/opt/app/prh/local/org.onap.prh.p12", - "keyStorePasswordPath": "change it", - "enableAaiCertAuth": "false", - "enableDmaapCertAuth": "false" + "streams_subscribes":{ + "ves-reg-output":{ + "dmaap_info":{ + "topic_url":"http://dmaap-mr:2222/events/unauthenticated.VES_PNFREG_OUTPUT" + } + } } } }
\ No newline at end of file diff --git a/prh-app-server/src/test/resources/flattened_configuration.json b/prh-app-server/src/test/resources/flattened_configuration.json index 48b45a80..7eb140bc 100644 --- a/prh-app-server/src/test/resources/flattened_configuration.json +++ b/prh-app-server/src/test/resources/flattened_configuration.json @@ -1,42 +1,76 @@ { - "config": { - "aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors": true, - "dmaap.dmaapProducerConfiguration.dmaapTopicName": "/events/unauthenticated.PNF_READY", - "dmaap.dmaapUpdateProducerConfiguration.dmaapTopicName": "/events/unauthenticated.PNF_UPDATE", - "dmaap.dmaapConsumerConfiguration.timeoutMs": -1, - "dmaap.dmaapConsumerConfiguration.dmaapHostName": "message-router.onap.svc.cluster.local", - "aai.aaiClientConfiguration.pnfUrl": "https://aai.onap.svc.cluster.local:8443/aai/v12/network/pnfs/pnf", - "aai.aaiClientConfiguration.aaiPnfPath": "/network/pnfs/pnf", - "aai.aaiClientConfiguration.aaiServiceInstancePath": "/business/customers/customer/${customer}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}", - "aai.aaiClientConfiguration.aaiUserPassword": "AAI", - "dmaap.dmaapConsumerConfiguration.dmaapUserName": "admin", - "aai.aaiClientConfiguration.aaiBasePath": "/aai/v12", - "dmaap.dmaapProducerConfiguration.dmaapPortNumber": 3904, - "aai.aaiClientConfiguration.aaiHost": "aai.onap.svc.cluster.local", - "dmaap.dmaapConsumerConfiguration.dmaapUserPassword": "admin", - "dmaap.dmaapProducerConfiguration.dmaapProtocol": "http", - "dmaap.dmaapProducerConfiguration.dmaapContentType": "application/json", - "dmaap.dmaapUpdateProducerConfiguration.dmaapProtocol": "http", - "dmaap.dmaapUpdateProducerConfiguration.dmaapContentType": "application/json", - "dmaap.dmaapConsumerConfiguration.dmaapTopicName": "/events/unauthenticated.SEC_OTHER_OUTPUT", - "dmaap.dmaapConsumerConfiguration.dmaapPortNumber": 3904, - "dmaap.dmaapConsumerConfiguration.dmaapContentType": "application/json", - "dmaap.dmaapConsumerConfiguration.messageLimit": -1, - "dmaap.dmaapConsumerConfiguration.dmaapProtocol": "http", - "aai.aaiClientConfiguration.aaiUserName": "AAI", - "dmaap.dmaapConsumerConfiguration.consumerId": "c12", - "dmaap.dmaapProducerConfiguration.dmaapHostName": "message-router.onap.svc.cluster.local", - "dmaap.dmaapUpdateProducerConfiguration.dmaapHostName": "message-router.onap.svc.cluster.local", - "aai.aaiClientConfiguration.aaiHostPortNumber": 8443, - "dmaap.dmaapConsumerConfiguration.consumerGroup": "OpenDCAE-c12", - "aai.aaiClientConfiguration.aaiProtocol": "https", - "dmaap.dmaapProducerConfiguration.dmaapUserName": "admin", - "dmaap.dmaapProducerConfiguration.dmaapUserPassword": "admin", - "security.trustStorePath": "/opt/app/prh/local/org.onap.prh.trust.jks", - "security.trustStorePasswordPath": "change_it", - "security.keyStorePath": "/opt/app/prh/local/org.onap.prh.p12", - "security.keyStorePasswordPath": "change_it", - "security.enableAaiCertAuth": false, - "security.enableDmaapCertAuth": false + "config":{ + "dmaap.dmaapConsumerConfiguration.dmaapUrl":"http://dmaap-mr:2222/events/unauthenticated.VES_PNFREG_OUTPUT", + "dmaap.dmaapConsumerConfiguration.dmaapHostName":"message-router.onap.svc.cluster.local", + "dmaap.dmaapConsumerConfiguration.dmaapPortNumber":3904, + "dmaap.dmaapConsumerConfiguration.dmaapTopicName":"/events/unauthenticated.SEC_OTHER_OUTPUT", + "dmaap.dmaapConsumerConfiguration.dmaapProtocol":"http", + "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.dmaapConsumerConfiguration.messageLimit":-1, + + "dmaap.dmaapProducerConfiguration.dmaapUrl":"http://dmaap-mr:2222/events/unauthenticated.PNF_READY", + "dmaap.dmaapProducerConfiguration.dmaapHostName":"message-router.onap.svc.cluster.local", + "dmaap.dmaapProducerConfiguration.dmaapPortNumber":3904, + "dmaap.dmaapProducerConfiguration.dmaapTopicName":"/events/unauthenticated.PNF_READY", + "dmaap.dmaapProducerConfiguration.dmaapProtocol":"http", + "dmaap.dmaapProducerConfiguration.dmaapUserName":"admin", + "dmaap.dmaapProducerConfiguration.dmaapUserPassword":"admin", + "dmaap.dmaapProducerConfiguration.dmaapContentType":"application/json", + "dmaap.dmaapUpdateProducerConfiguration.dmaapUrl":"http://dmaap-mr:2222/events/unauthenticated.PNF_UPDATE", + "dmaap.dmaapUpdateProducerConfiguration.dmaapHostName":"dmaap-mr", + "dmaap.dmaapUpdateProducerConfiguration.dmaapPortNumber":2223, + "dmaap.dmaapUpdateProducerConfiguration.dmaapTopicName":"events/unauthenticated.PNF_UPDATE", + "dmaap.dmaapUpdateProducerConfiguration.dmaapProtocol":"http", + "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.aaiHost":"aai.onap.svc.cluster.local", + "aai.aaiClientConfiguration.aaiHostPortNumber":8443, + "aai.aaiClientConfiguration.aaiProtocol":"https", + "aai.aaiClientConfiguration.aaiUserName":"AAI", + "aai.aaiClientConfiguration.aaiUserPassword":"AAI", + "aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors":true, + "aai.aaiClientConfiguration.aaiBasePath":"/aai/v12", + "aai.aaiClientConfiguration.aaiPnfPath":"/network/pnfs/pnf", + "aai.aaiClientConfiguration.aaiServiceInstancePath":"/business/customers/customer/${customer}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}", + "aai.aaiClientConfiguration.aaiHeaders":{ + "X-FromAppId":"prh", + "X-TransactionId":"9999", + "Accept":"application/json", + "Real-Time":"true", + "Authorization":"Basic QUFJOkFBSQ==" + }, + "security.trustStorePath":"/opt/app/prh/local/org.onap.prh.trust.jks", + "security.trustStorePasswordPath":"change_it", + "security.keyStorePath":"/opt/app/prh/local/org.onap.prh.p12", + "security.keyStorePasswordPath":"change_it", + "security.enableAaiCertAuth":false, + "security.enableDmaapCertAuth":false, + "streams_publishes":{ + "pnf-update":{ + "dmaap_info":{ + "topic_url":"http://dmaap-mr:2222/events/unauthenticated.PNF_UPDATE" + } + }, + "pnf-ready":{ + "dmaap_info":{ + "topic_url":"http://dmaap-mr:2222/events/unauthenticated.PNF_READY" + } + } + }, + "streams_subscribes":{ + "ves-reg-output":{ + "dmaap_info":{ + "topic_url":"http://dmaap-mr:2222/events/unauthenticated.VES_PNFREG_OUTPUT" + } + } + } } }
\ No newline at end of file diff --git a/prh-app-server/src/test/resources/incorrect_config.json b/prh-app-server/src/test/resources/incorrect_config.json deleted file mode 100644 index 89f72485..00000000 --- a/prh-app-server/src/test/resources/incorrect_config.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "configs": { - "aai": { - "aaiClientConfiguration": { - "pnfUrl": "https://localhost:8080/aai/v11/network/pnfs/pnf", - "aaiHost": "localhost", - "aaiPort": 8080, - "aaiIgnoreSslCertificateErrors": true, - "aaiProtocol": "https", - "aaiUserName": "admin", - "aaiUserPassword": "admin", - "aaiBasePath": "/aai/v11", - "aaiPnfPath": "/network/pnfs/pnf", - "aaiServiceInstancePath": "/business/customers/customer/${customer}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}", - "aaiHeaders": { - "X-FromAppId": "prh", - "X-TransactionId": "9999", - "Accept": "application/json", - "Real-Time": "true", - "Content-Type": "application/merge-patch+json", - "Authorization": "Basic QUFJOkFBSQ==" - } - } - }, - "dmaap": { - "dmaapConsumerConfiguration": { - "consumerGroup": "other", - "consumerId": "1", - "dmaapContentType": "application/json", - "dmaapHostName": "localhost", - "dmaapPortNumber": 2222, - "dmaapProtocol": "http", - "dmaapTopicName": "temp", - "dmaapUserName": "admin", - "dmaapUserPassword": "admin", - "messageLimit": 1000, - "timeoutMs": 1000 - }, - "dmaapProducerConfiguration": { - "dmaapContentType": "application/json", - "dmaapHostName": "localhost", - "dmaapPortNumber": 2223, - "dmaapProtocol": "http", - "dmaaptopicName": "temp", - "dmaapuserName": "admin", - "dmaapuserPassword": "admin" - }, - "dmaapUpdateProducerConfiguration": { - "dmaapContentType": "application/json", - "dmaapHostName": "localhost", - "dmaapPortNumber": 2223, - "dmaapProtocol": "http", - "dmaaptopicName": "temp2", - "dmaapuserName": "admin", - "dmaapuserPassword": "admin" - } - }, - "security": { - "trustStorePath": "/opt/app/prh/local/org.onap.prh.trust.jks", - "trustStorePasswordPath": "change it", - "keyStorePath": "/opt/app/prh/local/org.onap.prh.p12", - "keyStorePasswordPath": "change it", - "enableAaiCertAuth": "false", - "enableDmaapCertAuth": "false" - } - } -}
\ No newline at end of file |