From e6b79a67b2ad6e60e17a4f0e88a162e31a599870 Mon Sep 17 00:00:00 2001 From: Jakub Dudycz Date: Thu, 23 May 2019 14:47:19 +0200 Subject: Remove CloudHttpClient usages from dmaap-client module Signed-off-by: Jakub Dudycz Issue-ID: DCAEGEN2-1527 Change-Id: I8b5ddbf5231cb4848eb288300cf786bb549950cf --- .../client/config/DmaapConsumerConfiguration.java | 66 ------------- .../dmaap/client/config/DmaapCustomConfig.java | 106 -------------------- .../client/config/DmaapPublisherConfiguration.java | 46 --------- .../service/DMaaPAbstractReactiveHttpClient.java | 42 -------- .../client/service/DMaaPClientServiceUtils.java | 51 ---------- .../ConsumerReactiveHttpClientFactory.java | 45 --------- .../consumer/DMaaPConsumerReactiveHttpClient.java | 89 ----------------- .../consumer/DMaaPReactiveWebClientFactory.java | 65 ------------ .../producer/DMaaPPublisherReactiveHttpClient.java | 99 ------------------- .../service/producer/DmaaPRestTemplateFactory.java | 66 ------------- .../PublisherReactiveHttpClientFactory.java | 47 --------- .../dmaap/client/utlis/SecurityKeysUtil.java | 54 ---------- .../config/DmaapConsumerConfigurationTest.java | 87 ---------------- .../config/DmaapPublisherConfigurationTest.java | 76 -------------- .../service/DMaaPClientServiceUtilsTest.java | 43 -------- .../ConsumerReactiveHttpClientFactoryTest.java | 42 -------- .../DMaaPConsumerReactiveHttpClientTest.java | 92 ----------------- .../DMaaPReactiveWebClientFactoryTest.java | 110 --------------------- .../DMaaPPublisherReactiveHttpClientTest.java | 107 -------------------- .../producer/DmaaPRestTemplateFactoryTest.java | 58 ----------- .../PublisherReactiveHttpClientFactoryTest.java | 46 --------- 21 files changed, 1437 deletions(-) delete mode 100644 rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfiguration.java delete mode 100644 rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapCustomConfig.java delete mode 100644 rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapPublisherConfiguration.java delete mode 100644 rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPAbstractReactiveHttpClient.java delete mode 100644 rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPClientServiceUtils.java delete mode 100644 rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactory.java delete mode 100644 rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClient.java delete mode 100644 rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactory.java delete mode 100644 rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java delete mode 100644 rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactory.java delete mode 100644 rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactory.java delete mode 100644 rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/utlis/SecurityKeysUtil.java delete mode 100644 rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfigurationTest.java delete mode 100644 rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapPublisherConfigurationTest.java delete mode 100644 rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPClientServiceUtilsTest.java delete mode 100644 rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactoryTest.java delete mode 100644 rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClientTest.java delete mode 100644 rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactoryTest.java delete mode 100644 rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClientTest.java delete mode 100644 rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactoryTest.java delete mode 100644 rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactoryTest.java diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfiguration.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfiguration.java deleted file mode 100644 index 91e026af..00000000 --- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfiguration.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.config; - -import org.immutables.gson.Gson; -import org.immutables.value.Value; - -/** - * @author Przemysław Wąsala on 3/23/18 - * @deprecated Use new API {@link org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory} - */ -@Value.Immutable(prehash = true) -@Value.Style(builder = "new") -@Gson.TypeAdapters -@Deprecated -public abstract class DmaapConsumerConfiguration implements DmaapCustomConfig { - - private static final long serialVersionUID = 1L; - - public static DmaapConsumerConfiguration.Builder builder() { - return ImmutableDmaapConsumerConfiguration.builder(); - } - - @Value.Parameter - public abstract String consumerId(); - - @Value.Parameter - public abstract String consumerGroup(); - - @Value.Parameter - public abstract Integer timeoutMs(); - - @Value.Parameter - public abstract Integer messageLimit(); - - public interface Builder extends - DmaapCustomConfig.Builder { - - Builder consumerId(String consumerId); - - Builder consumerGroup(String consumerGroup); - - Builder timeoutMs(Integer timeoutMs); - - Builder messageLimit(Integer messageLimit); - } - -} \ No newline at end of file diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapCustomConfig.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapCustomConfig.java deleted file mode 100644 index 29c3a5e8..00000000 --- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapCustomConfig.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.config; - -import java.io.Serializable; -import org.immutables.value.Value; - -/** - * @author Przemysław Wąsala on 3/28/18 - * @deprecated Use new API {@link org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory} - */ -@Deprecated -public interface DmaapCustomConfig extends Serializable { - - @Deprecated - @Value.Parameter - String dmaapHostName(); - - @Deprecated - @Value.Parameter - Integer dmaapPortNumber(); - - @Deprecated - @Value.Parameter - String dmaapTopicName(); - - @Deprecated - @Value.Parameter - String dmaapProtocol(); - - @Value.Parameter - String dmaapUserName(); - - @Value.Parameter - String dmaapUserPassword(); - - @Value.Parameter - String dmaapContentType(); - - @Value.Parameter - String trustStorePath(); - - @Value.Parameter - String trustStorePasswordPath(); - - @Value.Parameter - String keyStorePath(); - - @Value.Parameter - String keyStorePasswordPath(); - - @Value.Parameter - Boolean enableDmaapCertAuth(); - - @Value.Parameter - String endpointUrl(); - - interface Builder> { - - B dmaapHostName(String dmaapHostName); - - B dmaapPortNumber(Integer dmaapPortNumber); - - B dmaapTopicName(String dmaapTopicName); - - B dmaapProtocol(String dmaapProtocol); - - B dmaapUserName(String dmaapUserName); - - B dmaapUserPassword(String dmaapUserPassword); - - B dmaapContentType(String dmaapContentType); - - B trustStorePath(String trustStorePath); - - B trustStorePasswordPath(String trustStorePasswordPath); - - B keyStorePath(String keyStore); - - B keyStorePasswordPath(String keyStorePass); - - B enableDmaapCertAuth(Boolean enableDmaapCertAuth); - - B endpointUrl(String endpointUrl); - - T build(); - } -} diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapPublisherConfiguration.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapPublisherConfiguration.java deleted file mode 100644 index df813705..00000000 --- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapPublisherConfiguration.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.config; - -import org.immutables.gson.Gson; -import org.immutables.value.Value; - -/** - * @author Przemysław Wąsala on 3/23/18 - * @deprecated Use new API {@link org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory} - */ -@Value.Immutable(prehash = true) -@Value.Style(builder = "new") -@Gson.TypeAdapters -@Deprecated -public abstract class DmaapPublisherConfiguration implements DmaapCustomConfig { - - private static final long serialVersionUID = 1L; - - public static DmaapPublisherConfiguration.Builder builder() { - return ImmutableDmaapPublisherConfiguration.builder(); - } - - interface Builder extends - DmaapCustomConfig.Builder { - - } -} diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPAbstractReactiveHttpClient.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPAbstractReactiveHttpClient.java deleted file mode 100644 index aee961ef..00000000 --- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPAbstractReactiveHttpClient.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service; - -import java.util.UUID; -import org.onap.dcaegen2.services.sdk.rest.services.model.logging.ImmutableRequestDiagnosticContext; -import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext; - -/** - * - * @deprecated Use new API {@link org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory} - */ -@Deprecated -public abstract class DMaaPAbstractReactiveHttpClient { - - protected final static String SLASH = "/"; - - protected RequestDiagnosticContext getRequestDiagnosticContext() { - return ImmutableRequestDiagnosticContext.builder() - .invocationId(UUID.randomUUID()).requestId(UUID.randomUUID()).build(); - } - - -} diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPClientServiceUtils.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPClientServiceUtils.java deleted file mode 100644 index 3b4f55ab..00000000 --- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPClientServiceUtils.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Marcin Migdal on 3/8/2019 - * @deprecated Use new API {@link org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory} - */ -@Deprecated -public final class DMaaPClientServiceUtils { - - public final static String CONTENT_TYPE = "Content-Type"; - - private DMaaPClientServiceUtils() { - - } - - /** - * Method generates headers for HTTP requests - * @param contentType contentType to be used in HTTP header* - * @return Map of Headers - * */ - public static Map getHeaders(String contentType) { - Map header = new HashMap<>(); - header.put(CONTENT_TYPE, contentType); - return header; - } - - -} diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactory.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactory.java deleted file mode 100644 index 5e1a0648..00000000 --- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactory.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service.consumer; - -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration; - -/** - * @author Przemysław Wąsala on 6/26/18 - * @deprecated Use new API {@link org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory} - */ -@Deprecated -public class ConsumerReactiveHttpClientFactory { - - private final DMaaPReactiveWebClientFactory reactiveWebClientFactory; - - public ConsumerReactiveHttpClientFactory( - DMaaPReactiveWebClientFactory reactiveWebClientFactory) { - this.reactiveWebClientFactory = reactiveWebClientFactory; - } - - public DMaaPConsumerReactiveHttpClient create( - DmaapConsumerConfiguration consumerConfiguration) { - return new DMaaPConsumerReactiveHttpClient(consumerConfiguration, - reactiveWebClientFactory.build(consumerConfiguration)); - } - -} diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClient.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClient.java deleted file mode 100644 index 83678d26..00000000 --- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClient.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service.consumer; - -import com.google.gson.JsonElement; -import java.net.URI; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; -import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPAbstractReactiveHttpClient; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPClientServiceUtils; -import org.onap.dcaegen2.services.sdk.rest.services.model.logging.ImmutableRequestDiagnosticContext; -import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext; -import org.onap.dcaegen2.services.sdk.rest.services.uri.URI.URIBuilder; -import reactor.core.publisher.Mono; - - -/** - * @author Przemysław Wąsala on 6/26/18 - * @deprecated Use new API {@link org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory} - */ -@Deprecated -public class DMaaPConsumerReactiveHttpClient extends DMaaPAbstractReactiveHttpClient { - - private final DmaapConsumerConfiguration consumerConfiguration; - private final CloudHttpClient cloudHttpClient; - - /** - * Constructor of DMaaPConsumerReactiveHttpClient. - * - * @param consumerConfiguration - DMaaP consumer configuration object - */ - - public DMaaPConsumerReactiveHttpClient(DmaapConsumerConfiguration consumerConfiguration, - CloudHttpClient cloudHttpClient) { - this.consumerConfiguration = consumerConfiguration; - this.cloudHttpClient = cloudHttpClient; - } - - /** - * Function for calling DMaaP HTTP consumer - consuming messages from Kafka/DMaaP from topic. - * - * @return reactive response from DMaaP in string format - */ - public Mono getDMaaPConsumerResponse( - Optional requestDiagnosticContextOptional) { - Map headers = DMaaPClientServiceUtils.getHeaders(consumerConfiguration.dmaapContentType()); - if (requestDiagnosticContextOptional.isPresent()) { - return cloudHttpClient - .get(getUri().toString(), requestDiagnosticContextOptional.get(), headers, JsonElement.class); - } - RequestDiagnosticContext requestDiagnosticContext = ImmutableRequestDiagnosticContext.builder() - .invocationId(UUID.randomUUID()).requestId(UUID.randomUUID()).build(); - return cloudHttpClient.get(getUri().toString(), requestDiagnosticContext, headers, JsonElement.class); - } - - URI getUri() { - return URI.create( - new URIBuilder().scheme(consumerConfiguration.dmaapProtocol()).host(consumerConfiguration.dmaapHostName()) - .port(consumerConfiguration.dmaapPortNumber()).path(createRequestPath()) - .build().toString()); - } - - private String createRequestPath() { - return new StringBuilder().append(SLASH).append(consumerConfiguration.dmaapTopicName()).append(SLASH) - .append(consumerConfiguration.consumerGroup()) - .append(SLASH).append(consumerConfiguration.consumerId()).toString(); - } -} diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactory.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactory.java deleted file mode 100644 index 65f0b608..00000000 --- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactory.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service.consumer; - -import io.netty.handler.ssl.SslContext; -import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.utlis.SecurityKeysUtil; -import org.onap.dcaegen2.services.sdk.security.ssl.SecurityKeys; -import org.onap.dcaegen2.services.sdk.security.ssl.SslFactory; - -/** - * @author Przemysław Wąsala on 7/4/18 - * @deprecated Use new API {@link org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory} - */ -@Deprecated -public class DMaaPReactiveWebClientFactory { - - private final SslFactory sslFactory; - - public DMaaPReactiveWebClientFactory() { - this(new SslFactory()); - } - - DMaaPReactiveWebClientFactory(SslFactory sslFactory) { - this.sslFactory = sslFactory; - } - - /** - * Construct CloudHttpClient with appropriate settings. - * - * @return CloudHttpClient - */ - - public CloudHttpClient build(DmaapConsumerConfiguration consumerConfiguration){ - SslContext sslContext = createSslContext(consumerConfiguration); - return new CloudHttpClient(sslContext); - } - - private SslContext createSslContext(DmaapConsumerConfiguration consumerConfiguration){ - if (consumerConfiguration.enableDmaapCertAuth()) { - final SecurityKeys securityKeys = SecurityKeysUtil.fromDmappCustomConfig(consumerConfiguration); - return sslFactory.createSecureClientContext(securityKeys); - } - return sslFactory.createInsecureClientContext(); - } -} diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java deleted file mode 100644 index 7173624d..00000000 --- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service.producer; - - -import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient; -import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPAbstractReactiveHttpClient; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPClientServiceUtils; -import org.onap.dcaegen2.services.sdk.rest.services.model.DmaapModel; -import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder; -import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext; -import org.onap.dcaegen2.services.sdk.rest.services.uri.URI.URIBuilder; -import reactor.core.publisher.Mono; - -import java.net.URI; -import java.util.Map; -import java.util.Optional; - - -/** - * @author Przemysław Wąsala on 7/4/18 - * @deprecated Use new API {@link org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory} - */ -@Deprecated -public class DMaaPPublisherReactiveHttpClient extends DMaaPAbstractReactiveHttpClient { - - private final DmaapPublisherConfiguration dmaapPublisherConfiguration; - private final JsonBodyBuilder jsonBodyBuilder; - private final CloudHttpClient cloudHttpClient; - - /** - * Constructor DMaaPPublisherReactiveHttpClient. - * - * @param dmaapPublisherConfiguration - DMaaP producer configuration object - * @param cloudHttpClient - cloudHttpClient sending http requests - */ - DMaaPPublisherReactiveHttpClient(DmaapPublisherConfiguration dmaapPublisherConfiguration, - CloudHttpClient cloudHttpClient, JsonBodyBuilder jsonBodyBuilder) { - this.dmaapPublisherConfiguration = dmaapPublisherConfiguration; - this.cloudHttpClient = cloudHttpClient; - this.jsonBodyBuilder = jsonBodyBuilder; - } - - /** - * Function for calling DMaaP HTTP producer - post request to DMaaP. - * - * @param dmaapModel - object which will be sent to DMaaP - * @return status code of operation - */ - - public Mono getDMaaPProducerResponse( - DmaapModel dmaapModel, - Optional requestDiagnosticContextOptional) { - return Mono.defer(() -> { - Map headers = DMaaPClientServiceUtils.getHeaders(dmaapPublisherConfiguration.dmaapContentType()); - if (requestDiagnosticContextOptional.isPresent()) { - cloudHttpClient - .post(getUri().toString(), requestDiagnosticContextOptional.get(), headers, jsonBodyBuilder, - dmaapModel); - } - return cloudHttpClient - .post(getUri().toString(), getRequestDiagnosticContext(), headers, jsonBodyBuilder, dmaapModel); - }); - } - - - URI getUri() { - return URI.create( - new URIBuilder().scheme(dmaapPublisherConfiguration.dmaapProtocol()) - .host(dmaapPublisherConfiguration.dmaapHostName()).port(dmaapPublisherConfiguration.dmaapPortNumber()) - .path(createRequestPath()) - .build().toString()); - } - - private String createRequestPath() { - return new StringBuilder().append(SLASH).append(dmaapPublisherConfiguration.dmaapTopicName()).toString(); - } - -} diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactory.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactory.java deleted file mode 100644 index 30079802..00000000 --- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service.producer; - -import io.netty.handler.ssl.SslContext; -import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.utlis.SecurityKeysUtil; -import org.onap.dcaegen2.services.sdk.security.ssl.SecurityKeys; -import org.onap.dcaegen2.services.sdk.security.ssl.SslFactory; - -/** - * - * @deprecated Use new API {@link org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory} - */ -@Deprecated -public class DmaaPRestTemplateFactory { - - private SslFactory sslFactory; - - public DmaaPRestTemplateFactory() { - this(new SslFactory()); - } - - DmaaPRestTemplateFactory(SslFactory sslFactory) { - this.sslFactory = sslFactory; - } - - /** - * Function for creating RestTemplate object. - * - * @param publisherConfiguration - DMaaP publisher configuration object - * @return RestTemplate with correct ssl configuration - */ - public CloudHttpClient build(DmaapPublisherConfiguration publisherConfiguration){ - SslContext sslContext = createSslContext(publisherConfiguration); - return new CloudHttpClient(sslContext); - } - - private SslContext createSslContext(DmaapPublisherConfiguration consumerConfiguration) { - if (consumerConfiguration.enableDmaapCertAuth()) { - final SecurityKeys securityKeys = SecurityKeysUtil - .fromDmappCustomConfig(consumerConfiguration); - return sslFactory.createSecureClientContext(securityKeys); - } - return sslFactory.createInsecureClientContext(); - } -} diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactory.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactory.java deleted file mode 100644 index 9e6cce27..00000000 --- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service.producer; - -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder; - -/** - * @deprecated Use new API {@link org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory} - */ -@Deprecated -public class PublisherReactiveHttpClientFactory { - - private final DmaaPRestTemplateFactory restTemplateFactory; - - private final JsonBodyBuilder jsonBodyBuilder; - - public PublisherReactiveHttpClientFactory(DmaaPRestTemplateFactory restTemplateFactory, - JsonBodyBuilder jsonBodyBuilder) { - this.restTemplateFactory = restTemplateFactory; - this.jsonBodyBuilder = jsonBodyBuilder; - } - - public DMaaPPublisherReactiveHttpClient create( - DmaapPublisherConfiguration publisherConfiguration) { - return new DMaaPPublisherReactiveHttpClient(publisherConfiguration, - restTemplateFactory.build(publisherConfiguration), jsonBodyBuilder); - } -} diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/utlis/SecurityKeysUtil.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/utlis/SecurityKeysUtil.java deleted file mode 100644 index c688ab0b..00000000 --- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/utlis/SecurityKeysUtil.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * Copyright (C) 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.sdk.rest.services.dmaap.client.utlis; - -import io.vavr.control.Try; -import java.nio.file.Path; -import java.nio.file.Paths; -import org.jetbrains.annotations.NotNull; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapCustomConfig; -import org.onap.dcaegen2.services.sdk.security.ssl.ImmutableSecurityKeys; -import org.onap.dcaegen2.services.sdk.security.ssl.ImmutableSecurityKeysStore; -import org.onap.dcaegen2.services.sdk.security.ssl.Passwords; -import org.onap.dcaegen2.services.sdk.security.ssl.SecurityKeys; - -/** - * @deprecated Use new API {@link org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory} - */ -@Deprecated -public final class SecurityKeysUtil { - - private SecurityKeysUtil(){ - - } - - public static @NotNull SecurityKeys fromDmappCustomConfig(DmaapCustomConfig configuration){ - return ImmutableSecurityKeys.builder() - .keyStore(ImmutableSecurityKeysStore.of(resource(configuration.keyStorePath()).get())) - .keyStorePassword(Passwords.fromResource(configuration.keyStorePasswordPath())) - .trustStore(ImmutableSecurityKeysStore.of(resource(configuration.trustStorePath()).get())) - .trustStorePassword(Passwords.fromResource(configuration.trustStorePasswordPath())) - .build(); - } - - private static Try resource(String resource) { - return Try.of(() -> Paths.get(Passwords.class.getResource(resource).toURI())); - }} diff --git a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfigurationTest.java b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfigurationTest.java deleted file mode 100644 index 8ae5e62d..00000000 --- a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfigurationTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.config; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapConsumerConfiguration; - -class DmaapConsumerConfigurationTest { - - @Test - void builder_shouldBuildConfigurationObject() { - - // Given - DmaapConsumerConfiguration configuration; - String consumerId = "1"; - String dmaapHostName = "localhost"; - Integer dmaapPortNumber = 2222; - String dmaapTopicName = "temp"; - String dmaapProtocol = "http"; - String dmaapUserName = "admin"; - String dmaapUserPassword = "admin"; - String dmaapContentType = "application/json"; - String consumerGroup = "other"; - Integer timeoutMs = 1000; - Integer messageLimit = 1000; - String trustStorePath = "trustStorePath"; - String trustStorePasswordPath = "trustStorePasswordPath"; - String keyStorePath = "keyStorePath"; - String keyStorePasswordPath = "keyStorePasswordPath"; - Boolean enableDmaapCertAuth = true; - String endpointUrl = "http://dmaap-mr:8080/events/topic"; - - - // When - configuration = new ImmutableDmaapConsumerConfiguration.Builder() - .consumerId(consumerId) - .dmaapHostName(dmaapHostName) - .dmaapPortNumber(dmaapPortNumber) - .dmaapTopicName(dmaapTopicName) - .dmaapProtocol(dmaapProtocol) - .dmaapUserName(dmaapUserName) - .dmaapUserPassword(dmaapUserPassword) - .dmaapContentType(dmaapContentType) - .consumerGroup(consumerGroup) - .timeoutMs(timeoutMs) - .messageLimit(messageLimit) - .trustStorePath(trustStorePath) - .trustStorePasswordPath(trustStorePasswordPath) - .keyStorePath(keyStorePath) - .keyStorePasswordPath(keyStorePasswordPath) - .enableDmaapCertAuth(enableDmaapCertAuth) - .endpointUrl(endpointUrl) - .build(); - - // Then - assertEquals("DmaapConsumerConfiguration{" - + "consumerId=1, consumerGroup=other, timeoutMs=1000, messageLimit=1000, dmaapHostName=localhost, " - + "dmaapPortNumber=2222, dmaapTopicName=temp, dmaapProtocol=http, dmaapUserName=admin, " - + "dmaapUserPassword=admin, dmaapContentType=application/json, " - + "trustStorePath=trustStorePath, trustStorePasswordPath=trustStorePasswordPath, " - + "keyStorePath=keyStorePath, keyStorePasswordPath=keyStorePasswordPath, enableDmaapCertAuth=true, " - + "endpointUrl=http://dmaap-mr:8080/events/topic}", - configuration.toString()); - - } -} diff --git a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapPublisherConfigurationTest.java b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapPublisherConfigurationTest.java deleted file mode 100644 index 0bbd1650..00000000 --- a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapPublisherConfigurationTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.config; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapPublisherConfiguration; - -class DmaapPublisherConfigurationTest { - - - @Test - void builder_shouldBuildConfigurationObject() { - - // Given - DmaapPublisherConfiguration configuration; - String dmaapHostName = "localhost"; - Integer dmaapPortNumber = 2222; - String dmaapTopicName = "temp"; - String dmaapProtocol = "http"; - String dmaapUserName = "admin"; - String dmaapUserPassword = "admin"; - String dmaapContentType = "application/json"; - String trustStorePath = "trustStorePath"; - String trustStorePasswordPath = "trustStorePasswordPath"; - String keyStorePath = "keyStorePath"; - String keyStorePasswordPath = "keyStorePasswordPath"; - Boolean enableDmaapCertAuth = true; - String endpointUrl = "http://dmaap-mr:8080/events/topic"; - - // When - configuration = new ImmutableDmaapPublisherConfiguration.Builder() - .dmaapHostName(dmaapHostName) - .dmaapPortNumber(dmaapPortNumber) - .dmaapTopicName(dmaapTopicName) - .dmaapProtocol(dmaapProtocol) - .dmaapUserName(dmaapUserName) - .dmaapUserPassword(dmaapUserPassword) - .dmaapContentType(dmaapContentType) - .trustStorePath(trustStorePath) - .trustStorePasswordPath(trustStorePasswordPath) - .keyStorePath(keyStorePath) - .keyStorePasswordPath(keyStorePasswordPath) - .enableDmaapCertAuth(enableDmaapCertAuth) - .endpointUrl(endpointUrl) - .build(); - - // Then - assertEquals("DmaapPublisherConfiguration{dmaapHostName=localhost, dmaapPortNumber=2222, " - + "dmaapTopicName=temp, dmaapProtocol=http, dmaapUserName=admin, dmaapUserPassword=admin, " - + "dmaapContentType=application/json, trustStorePath=trustStorePath, " - + "trustStorePasswordPath=trustStorePasswordPath, keyStorePath=keyStorePath, " - + "keyStorePasswordPath=keyStorePasswordPath, enableDmaapCertAuth=true, " - + "endpointUrl=http://dmaap-mr:8080/events/topic}", configuration.toString()); - } -} diff --git a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPClientServiceUtilsTest.java b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPClientServiceUtilsTest.java deleted file mode 100644 index 58f23b35..00000000 --- a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPClientServiceUtilsTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service; - -import java.util.Map; -import static org.junit.jupiter.api.Assertions.*; -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPClientServiceUtils; - -public class DMaaPClientServiceUtilsTest { - - - private final static String contentType = "myType"; - - @Test - public void getHeaders(){ - - Map headres = DMaaPClientServiceUtils.getHeaders(contentType); - assertEquals(1,headres.size()); - assertEquals(contentType,headres.get(DMaaPClientServiceUtils.CONTENT_TYPE)); - - } - - -} diff --git a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactoryTest.java b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactoryTest.java deleted file mode 100644 index e356f179..00000000 --- a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactoryTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service.consumer; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration; - -class ConsumerReactiveHttpClientFactoryTest { - - private DmaapConsumerConfiguration dmaapConsumerConfiguration = mock(DmaapConsumerConfiguration.class); - private DMaaPReactiveWebClientFactory reactiveWebClientFactory = mock(DMaaPReactiveWebClientFactory.class); - private ConsumerReactiveHttpClientFactory httpClientFactory = - new ConsumerReactiveHttpClientFactory(reactiveWebClientFactory); - - @Test - void create_shouldReturnNotNullFactoryInstance() throws Exception { - Assertions.assertNotNull(httpClientFactory.create(dmaapConsumerConfiguration)); - verify(reactiveWebClientFactory).build(dmaapConsumerConfiguration); - } -} \ No newline at end of file diff --git a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClientTest.java b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClientTest.java deleted file mode 100644 index 5a29fff0..00000000 --- a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClientTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service.consumer; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.gson.JsonElement; -import java.net.URI; -import java.util.Optional; -import org.apache.http.entity.ContentType; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPClientServiceUtils; -import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -/** - * @author Przemysław Wąsala on 6/27/18 - */ -class DMaaPConsumerReactiveHttpClientTest { - - private static final String JSON_MESSAGE = "{ \"responseFromDmaap\": \"Success\"}"; - private DMaaPConsumerReactiveHttpClient dmaapConsumerReactiveHttpClient; - private DmaapConsumerConfiguration consumerConfigurationMock = mock(DmaapConsumerConfiguration.class); - private Mono expectedResult; - private CloudHttpClient httpClient = mock(CloudHttpClient.class); - private URI exampleTestUri = URI - .create("https://54.45.33.2:1234/unauthenticated.SEC_OTHER_OUTPUT/OpenDCAE-c12/c12"); - private RequestDiagnosticContext requestDiagnosticContext = mock(RequestDiagnosticContext.class); - - @BeforeEach - void setUp() { - when(consumerConfigurationMock.dmaapHostName()).thenReturn("54.45.33.2"); - when(consumerConfigurationMock.dmaapProtocol()).thenReturn("https"); - when(consumerConfigurationMock.dmaapPortNumber()).thenReturn(1234); - when(consumerConfigurationMock.dmaapUserName()).thenReturn("PRH"); - when(consumerConfigurationMock.dmaapUserPassword()).thenReturn("PRH"); - when(consumerConfigurationMock.dmaapContentType()).thenReturn(ContentType.APPLICATION_JSON.getMimeType()); - when(consumerConfigurationMock.dmaapTopicName()).thenReturn("unauthenticated.SEC_OTHER_OUTPUT"); - when(consumerConfigurationMock.consumerGroup()).thenReturn("OpenDCAE-c12"); - when(consumerConfigurationMock.consumerId()).thenReturn("c12"); - dmaapConsumerReactiveHttpClient = new DMaaPConsumerReactiveHttpClient(consumerConfigurationMock, httpClient); - } - - @Test - void getHttpResponse_Success() { - //given - expectedResult = Mono.just(mock(JsonElement.class)); - when(httpClient.get(exampleTestUri.toString(), requestDiagnosticContext, - DMaaPClientServiceUtils.getHeaders(ContentType.APPLICATION_JSON.getMimeType()), JsonElement.class)) - .thenReturn(expectedResult); - //when - Mono response = dmaapConsumerReactiveHttpClient - .getDMaaPConsumerResponse(Optional.of(requestDiagnosticContext)); - //then - StepVerifier.create(response).expectSubscription() - .expectNextMatches(results -> { - Assertions.assertEquals(results, expectedResult.block()); - return true; - }).verifyComplete(); - } - - @Test - void getAppropriateUri_whenPassingCorrectedPathForPnf() { - Assertions.assertEquals(dmaapConsumerReactiveHttpClient.getUri(), exampleTestUri); - } - - -} \ No newline at end of file diff --git a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactoryTest.java b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactoryTest.java deleted file mode 100644 index 9d670c65..00000000 --- a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactoryTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service.consumer; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import io.netty.handler.ssl.SslContext; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.utlis.SecurityKeysUtil; -import org.onap.dcaegen2.services.sdk.security.ssl.SecurityKeys; -import org.onap.dcaegen2.services.sdk.security.ssl.SslFactory; - - -/** - * @author Przemysław Wąsala on 7/5/18 - */ -class DMaaPReactiveWebClientFactoryTest { - - private static final String KEY_STORE_RESOURCE_PATH = "/org.onap.dcae.jks"; - private static final String KEY_STORE_PASS_RESOURCE_PATH = "/keystore.password"; - private static final String TRUST_STORE_RESOURCE_PATH = "/org.onap.dcae.trust.jks"; - private static final String TRUST_STORE_PASS_RESOURCE_PATH = "/truststore.password"; - private SslFactory sslFactory = mock(SslFactory.class); - private SslContext dummySslContext = mock(SslContext.class); - private DMaaPReactiveWebClientFactory webClientFactory = new DMaaPReactiveWebClientFactory(sslFactory); - private ArgumentCaptor securityKeysArgumentCaptor = ArgumentCaptor - .forClass(SecurityKeys.class); - - @Test - void builder_shouldBuildDMaaPReactiveWebClientwithInsecureSslContext(){ - //given - DmaapConsumerConfiguration dmaapConsumerConfiguration = givenDmaapConfigurationWithSslDisabled(); - - //when - CloudHttpClient dmaapReactiveWebClient = webClientFactory.build(dmaapConsumerConfiguration); - - //then - assertNotNull(dmaapReactiveWebClient); - verify(sslFactory).createInsecureClientContext(); - } - - @Test - void builder_shouldBuildDMaaPReactiveWebClientwithSecureSslContext(){ - //given - DmaapConsumerConfiguration dmaapConsumerConfiguration = givenDmaapConfigurationWithSslEnabled(); - SecurityKeys givenKeys = SecurityKeysUtil.fromDmappCustomConfig(dmaapConsumerConfiguration); - - //when - CloudHttpClient dmaapReactiveWebClient = webClientFactory.build(dmaapConsumerConfiguration); - - //then - assertNotNull(dmaapReactiveWebClient); - - verify(sslFactory).createSecureClientContext(securityKeysArgumentCaptor.capture()); - - SecurityKeys capturedKeys = securityKeysArgumentCaptor.getValue(); - - assertEquals(capturedKeys.keyStore().path(), givenKeys.keyStore().path()); - assertEquals(capturedKeys.keyStorePassword().toString(), givenKeys.keyStorePassword().toString()); - assertEquals(capturedKeys.trustStore().path(), givenKeys.trustStore().path()); - assertEquals(capturedKeys.trustStorePassword().toString(), givenKeys.trustStorePassword().toString()); - } - - private DmaapConsumerConfiguration givenDmaapConfigurationWithSslDisabled(){ - DmaapConsumerConfiguration dmaapConsumerConfiguration = mock(DmaapConsumerConfiguration.class); - when(dmaapConsumerConfiguration.enableDmaapCertAuth()).thenReturn(false); - when(sslFactory.createInsecureClientContext()).thenReturn(dummySslContext); - return dmaapConsumerConfiguration; - } - - private DmaapConsumerConfiguration givenDmaapConfigurationWithSslEnabled(){ - DmaapConsumerConfiguration dmaapConsumerConfiguration = mock(DmaapConsumerConfiguration.class); - - when(dmaapConsumerConfiguration.enableDmaapCertAuth()).thenReturn(true); - when(dmaapConsumerConfiguration.keyStorePath()).thenReturn(KEY_STORE_RESOURCE_PATH); - when(dmaapConsumerConfiguration.keyStorePasswordPath()).thenReturn(KEY_STORE_PASS_RESOURCE_PATH); - when(dmaapConsumerConfiguration.trustStorePath()).thenReturn(TRUST_STORE_RESOURCE_PATH); - when(dmaapConsumerConfiguration.trustStorePasswordPath()).thenReturn(TRUST_STORE_PASS_RESOURCE_PATH); - - when(sslFactory.createSecureClientContext(any(SecurityKeys.class))).thenReturn(dummySslContext); - - return dmaapConsumerConfiguration; - } -} \ No newline at end of file diff --git a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClientTest.java b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClientTest.java deleted file mode 100644 index 4f58ffbd..00000000 --- a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClientTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service.producer; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.net.URI; -import java.util.Optional; -import org.apache.http.entity.ContentType; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient; -import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPClientServiceUtils; -import org.onap.dcaegen2.services.sdk.rest.services.model.ClientModel; -import org.onap.dcaegen2.services.sdk.rest.services.model.DmaapModel; -import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder; -import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; -import reactor.netty.http.client.HttpClientResponse; - -/** - * @author Przemysław Wąsala on 7/4/18 - */ - -class DMaaPPublisherReactiveHttpClientTest { - - private DMaaPPublisherReactiveHttpClient dmaapPublisherReactiveHttpClient; - private DmaapPublisherConfiguration dmaapPublisherConfigurationMock = mock(DmaapPublisherConfiguration.class); - private CloudHttpClient cloudHttpClientMock = mock(CloudHttpClient.class); - private DmaapModel dmaapModelMock = mock(DmaapModel.class); - private JsonBodyBuilder jsonBodyBuilderMock = mock(JsonBodyBuilder.class); - private Optional requestDiagnosticContextOptionalMock = Optional - .of(mock(RequestDiagnosticContext.class)); - - @BeforeEach - void setUp() { - when(dmaapPublisherConfigurationMock.dmaapHostName()).thenReturn("54.45.33.2"); - when(dmaapPublisherConfigurationMock.dmaapProtocol()).thenReturn("https"); - when(dmaapPublisherConfigurationMock.dmaapPortNumber()).thenReturn(1234); - when(dmaapPublisherConfigurationMock.dmaapUserName()).thenReturn("PRH"); - when(dmaapPublisherConfigurationMock.dmaapUserPassword()).thenReturn("PRH"); - when(dmaapPublisherConfigurationMock.dmaapContentType()).thenReturn("application/json"); - when(dmaapPublisherConfigurationMock.dmaapTopicName()).thenReturn("unauthenticated.PNF_READY"); - - when(jsonBodyBuilderMock.createJsonBody(dmaapModelMock)).thenReturn( - "{\"correlationId\":\"NOKnhfsadhff\"," + - "\"ipaddress-v4\":\"256.22.33.155\", " + - "\"ipaddress-v6\":\"200J:0db8:85a3:0000:0000:8a2e:0370:7334\"}"); - - dmaapPublisherReactiveHttpClient = - new DMaaPPublisherReactiveHttpClient(dmaapPublisherConfigurationMock, cloudHttpClientMock, - jsonBodyBuilderMock); - } - - @Test - void getHttpResponse_Success() { - //given - Mono expectedResult = Mono.just(mock(HttpResponse.class)); - //when - when( - cloudHttpClientMock - .post(getUri().toString(), requestDiagnosticContextOptionalMock.get(), - DMaaPClientServiceUtils.getHeaders(ContentType.APPLICATION_JSON.getMimeType()), - jsonBodyBuilderMock, - mock(ClientModel.class))) - .thenReturn(Mono.just(mock(HttpResponse.class))); - //then - StepVerifier.create(expectedResult).expectSubscription() - .expectNextMatches(results -> { - Assertions.assertEquals(results, expectedResult.block()); - return true; - }).verifyComplete(); - } - - @Test - void getAppropriateUri_whenPassingCorrectedPathForPnf() { - Assertions.assertEquals(dmaapPublisherReactiveHttpClient.getUri(), - getUri()); - } - - private URI getUri() { - return URI.create("https://54.45.33.2:1234/unauthenticated.PNF_READY"); - } -} \ No newline at end of file diff --git a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactoryTest.java b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactoryTest.java deleted file mode 100644 index 80cf2243..00000000 --- a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactoryTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service.producer; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration; - - -class DmaaPRestTemplateFactoryTest { - - private static final String KEY_STORE_RESOURCE_PATH = "/org.onap.dcae.jks"; - private static final String KEYSTORE_PASSWORD_RESOURCE_PATH = "/keystore.password"; - private static final String TRUSTSTORE_PASSWORD_RESOURCE_PATH = "/truststore.password"; - private static final String TRUST_STORE_RESOURCE_PATH = "/org.onap.dcae.trust.jks"; - private DmaapPublisherConfiguration publisherConfiguration = mock(DmaapPublisherConfiguration.class); - private DmaaPRestTemplateFactory factory = new DmaaPRestTemplateFactory(); - - @Test - void build_shouldCreateRestTemplateWithoutSslConfiguration(){ - when(publisherConfiguration.enableDmaapCertAuth()).thenReturn(false); - - Assertions.assertNotNull(factory.build(publisherConfiguration)); - } - - @Test - void build_shouldCreateRestTemplateWithSslConfiguration() { - when(publisherConfiguration.enableDmaapCertAuth()).thenReturn(true); - when(publisherConfiguration.keyStorePath()).thenReturn(KEY_STORE_RESOURCE_PATH); - when(publisherConfiguration.keyStorePasswordPath()).thenReturn( - KEYSTORE_PASSWORD_RESOURCE_PATH); - when(publisherConfiguration.trustStorePath()).thenReturn(TRUST_STORE_RESOURCE_PATH); - when(publisherConfiguration.trustStorePasswordPath()).thenReturn( - TRUSTSTORE_PASSWORD_RESOURCE_PATH); - - Assertions.assertNotNull(factory.build(publisherConfiguration)); - } -} \ No newline at end of file diff --git a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactoryTest.java b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactoryTest.java deleted file mode 100644 index 55c2e233..00000000 --- a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactoryTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * 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.sdk.rest.services.dmaap.client.service.producer; - -import static org.mockito.Mockito.mock; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration; -import org.onap.dcaegen2.services.sdk.rest.services.model.DmaapModel; -import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder; - - -class PublisherReactiveHttpClientFactoryTest { - - private DmaaPRestTemplateFactory restTemplateFactory = mock(DmaaPRestTemplateFactory.class); - private DmaapPublisherConfiguration dmaapPublisherConfiguration = mock( - DmaapPublisherConfiguration.class); - private JsonBodyBuilder jsonBodyBuilder = mock(JsonBodyBuilder.class); - - private PublisherReactiveHttpClientFactory httpClientFactory = - new PublisherReactiveHttpClientFactory(restTemplateFactory, jsonBodyBuilder); - - @Test - void create_shouldReturnNotNullFactoryInstance() { - Assertions.assertNotNull(httpClientFactory.create(dmaapPublisherConfiguration)); - } -} -- cgit 1.2.3-korg