aboutsummaryrefslogtreecommitdiffstats
path: root/rest-services/dmaap-client/src/test
diff options
context:
space:
mode:
authorJakub Dudycz <jakub.dudycz@nokia.com>2019-05-23 14:47:19 +0200
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>2019-05-23 13:34:35 +0000
commite6b79a67b2ad6e60e17a4f0e88a162e31a599870 (patch)
tree48669e33f996536cfe15a9919a4e7fff9f3e257d /rest-services/dmaap-client/src/test
parenta952590339504e30e1f88f638cd465c4cc4ea1c7 (diff)
Remove CloudHttpClient usages from dmaap-client module
Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com> Issue-ID: DCAEGEN2-1527 Change-Id: I8b5ddbf5231cb4848eb288300cf786bb549950cf
Diffstat (limited to 'rest-services/dmaap-client/src/test')
-rw-r--r--rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfigurationTest.java87
-rw-r--r--rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapPublisherConfigurationTest.java76
-rw-r--r--rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPClientServiceUtilsTest.java43
-rw-r--r--rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactoryTest.java42
-rw-r--r--rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClientTest.java92
-rw-r--r--rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactoryTest.java110
-rw-r--r--rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClientTest.java107
-rw-r--r--rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactoryTest.java58
-rw-r--r--rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactoryTest.java46
9 files changed, 0 insertions, 661 deletions
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<String,String> 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 <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> 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<JsonElement> 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<JsonElement> 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 <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> 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<SecurityKeys> 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 <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> 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<DmaapModel> jsonBodyBuilderMock = mock(JsonBodyBuilder.class);
- private Optional<RequestDiagnosticContext> 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<HttpResponse> 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<DmaapModel> jsonBodyBuilder = mock(JsonBodyBuilder.class);
-
- private PublisherReactiveHttpClientFactory httpClientFactory =
- new PublisherReactiveHttpClientFactory(restTemplateFactory, jsonBodyBuilder);
-
- @Test
- void create_shouldReturnNotNullFactoryInstance() {
- Assertions.assertNotNull(httpClientFactory.create(dmaapPublisherConfiguration));
- }
-}