diff options
author | 2018-12-04 12:56:19 +0100 | |
---|---|---|
committer | 2018-12-04 12:56:19 +0100 | |
commit | aa9576a7cceb70220fdc55fadef6c7d0e4dac452 (patch) | |
tree | 8b7b692f18855b3cc3d3ab94addcfcff91a0d18b /prh-dmaap-client/src/test | |
parent | 19ff70fb04bf4fa6fc01d89c4de02e0c4d60300e (diff) |
SDK integration: use dmaap client in PRH
Change-Id: I41a952396fb9714f7e1e04c1d08a1e27df3020db
Issue-ID: DCAEGEN2-1013
Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'prh-dmaap-client/src/test')
13 files changed, 0 insertions, 612 deletions
diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapConsumerConfigurationTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapConsumerConfigurationTest.java deleted file mode 100644 index 54193edd..00000000 --- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapConsumerConfigurationTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.services.prh.service.config; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration; -import org.onap.dcaegen2.services.prh.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; - - // 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) - .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}", - configuration.toString()); - - } -} diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapPublisherConfigurationTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapPublisherConfigurationTest.java deleted file mode 100644 index 472abec5..00000000 --- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapPublisherConfigurationTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.services.prh.service.config; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration; -import org.onap.dcaegen2.services.prh.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; - - // 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) - .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}", configuration.toString()); - } -} diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/ConsumerReactiveHttpClientFactoryTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/ConsumerReactiveHttpClientFactoryTest.java deleted file mode 100644 index a75b21de..00000000 --- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/ConsumerReactiveHttpClientFactoryTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.services.prh.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.prh.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/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java deleted file mode 100644 index 256d3c21..00000000 --- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.services.prh.service.consumer; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; -import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication; - -import java.net.URI; -import java.net.URISyntaxException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration; -import org.springframework.http.HttpHeaders; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClient.RequestHeadersUriSpec; -import org.springframework.web.reactive.function.client.WebClient.ResponseSpec; -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<String> expectedResult = Mono.empty(); - private WebClient webClient; - private RequestHeadersUriSpec requestHeadersSpec; - private ResponseSpec responseSpec; - - - @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("application/json"); - when(consumerConfigurationMock.dmaapTopicName()).thenReturn("unauthenticated.SEC_OTHER_OUTPUT"); - when(consumerConfigurationMock.consumerGroup()).thenReturn("OpenDCAE-c12"); - when(consumerConfigurationMock.consumerId()).thenReturn("c12"); - - webClient = spy(WebClient.builder() - .defaultHeader(HttpHeaders.CONTENT_TYPE, consumerConfigurationMock.dmaapContentType()) - .filter(basicAuthentication(consumerConfigurationMock.dmaapUserName(), - consumerConfigurationMock.dmaapUserPassword())) - .build()); - dmaapConsumerReactiveHttpClient = new DMaaPConsumerReactiveHttpClient(consumerConfigurationMock, webClient); - requestHeadersSpec = mock(RequestHeadersUriSpec.class); - responseSpec = mock(ResponseSpec.class); - } - - - @Test - void getHttpResponse_Success() { - //given - expectedResult = Mono.just(JSON_MESSAGE); - - //when - mockDependantObjects(); - doReturn(expectedResult).when(responseSpec).bodyToMono(String.class); - Mono<String> response = dmaapConsumerReactiveHttpClient.getDMaaPConsumerResponse(); - - //then - StepVerifier.create(response).expectSubscription() - .expectNextMatches(results -> { - Assertions.assertEquals(results, expectedResult.block()); - return true; - }).verifyComplete(); - } - - @Test - void getAppropriateUri_whenPassingCorrectedPathForPnf() { - Assertions.assertEquals(dmaapConsumerReactiveHttpClient.getUri(), - URI.create("https://54.45.33.2:1234/unauthenticated.SEC_OTHER_OUTPUT/OpenDCAE-c12/c12")); - } - - private void mockDependantObjects() { - when(webClient.get()).thenReturn(requestHeadersSpec); - when(requestHeadersSpec.uri((URI) any())).thenReturn(requestHeadersSpec); - when(requestHeadersSpec.headers(any())).thenReturn(requestHeadersSpec); - when(requestHeadersSpec.retrieve()).thenReturn(responseSpec); - doReturn(responseSpec).when(responseSpec).onStatus(any(), any()); - } - -}
\ No newline at end of file diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPReactiveWebClientFactoryTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPReactiveWebClientFactoryTest.java deleted file mode 100644 index b2cd84c6..00000000 --- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPReactiveWebClientFactoryTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.services.prh.service.consumer; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration; -import org.onap.dcaegen2.services.prh.ssl.SslFactory; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * @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 = "keyStore"; - private static final String KEY_STORE_PASS = "keyStorePass"; - private static final String TRUST_STORE = "trustStore"; - private static final String TRUST_STORE_PASS = "trustStorePass"; - private SslFactory sslFactory = mock(SslFactory.class); - private DMaaPReactiveWebClientFactory webClientFactory = new DMaaPReactiveWebClientFactory(sslFactory); - - @Test - void builder_shouldBuildDMaaPReactiveWebClientwithInsecureSslContext() throws Exception { - //given - DmaapConsumerConfiguration dmaapConsumerConfiguration = givenDmaapConfigurationWithSslDisabled(); - - //when - WebClient dmaapReactiveWebClient = webClientFactory.build(dmaapConsumerConfiguration); - - //then - Assertions.assertNotNull(dmaapReactiveWebClient); - verify(sslFactory).createInsecureContext(); - } - - @Test - void builder_shouldBuildDMaaPReactiveWebClientwithSecureSslContext() throws Exception { - //given - DmaapConsumerConfiguration dmaapConsumerConfiguration = givenDmaapConfigurationWithSslEnabled(); - - //when - WebClient dmaapReactiveWebClient = webClientFactory.build(dmaapConsumerConfiguration); - - //then - Assertions.assertNotNull(dmaapReactiveWebClient); - verify(sslFactory).createSecureContext(KEY_STORE, KEY_STORE_PASS, TRUST_STORE, TRUST_STORE_PASS); - } - - private DmaapConsumerConfiguration givenDmaapConfigurationWithSslDisabled() { - DmaapConsumerConfiguration dmaapConsumerConfiguration = mock(DmaapConsumerConfiguration.class); - when(dmaapConsumerConfiguration.enableDmaapCertAuth()).thenReturn(false); - return dmaapConsumerConfiguration; - } - - private DmaapConsumerConfiguration givenDmaapConfigurationWithSslEnabled() { - DmaapConsumerConfiguration dmaapConsumerConfiguration = mock(DmaapConsumerConfiguration.class); - when(dmaapConsumerConfiguration.enableDmaapCertAuth()).thenReturn(true); - when(dmaapConsumerConfiguration.keyStorePath()).thenReturn(KEY_STORE); - when(dmaapConsumerConfiguration.keyStorePasswordPath()).thenReturn(KEY_STORE_PASS); - when(dmaapConsumerConfiguration.trustStorePath()).thenReturn(TRUST_STORE); - when(dmaapConsumerConfiguration.trustStorePasswordPath()).thenReturn(TRUST_STORE_PASS); - return dmaapConsumerConfiguration; - } -}
\ No newline at end of file diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPPublisherReactiveHttpClientTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPPublisherReactiveHttpClientTest.java deleted file mode 100644 index a163fb74..00000000 --- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPPublisherReactiveHttpClientTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.services.prh.service.producer; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.net.URI; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration; -import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel; -import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModelForUnitTest; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -/** - * @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 ConsumerDmaapModel consumerDmaapModel = new ConsumerDmaapModelForUnitTest(); - private RestTemplate restTemplate = mock(RestTemplate.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"); - dmaapPublisherReactiveHttpClient = - new DMaaPPublisherReactiveHttpClient(dmaapPublisherConfigurationMock, Mono.just(restTemplate)); - - } - - @Test - void getHttpResponse_Success() { - //given - int responseSuccess = 200; - ResponseEntity<String> mockedResponseEntity = mock(ResponseEntity.class); - //when - when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.valueOf(responseSuccess)); - doReturn(mockedResponseEntity).when(restTemplate) - .exchange(any(URI.class), any(HttpMethod.class), any(HttpEntity.class), (Class<Object>) any()); - - //then - StepVerifier.create(dmaapPublisherReactiveHttpClient.getDMaaPProducerResponse(consumerDmaapModel)) - .expectSubscription().expectNext(mockedResponseEntity).verifyComplete(); - } - - @Test - void getAppropriateUri_whenPassingCorrectedPathForPnf() { - Assertions.assertEquals(dmaapPublisherReactiveHttpClient.getUri(), - URI.create("https://54.45.33.2:1234/unauthenticated.PNF_READY")); - } -}
\ No newline at end of file diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/DmaaPRestTemplateFactoryTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/DmaaPRestTemplateFactoryTest.java deleted file mode 100644 index 97303b35..00000000 --- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/DmaaPRestTemplateFactoryTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.services.prh.service.producer; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import javax.net.ssl.SSLException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration; - - -class DmaaPRestTemplateFactoryTest { - - private static final String KEY_STORE = "org.onap.dcae.jks"; - private static final String KEYSTORE_PASSWORD = "keystore.password"; - private static final String TRUSTSTORE_PASSWORD = "truststore.password"; - private static final String TRUST_STORE = "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).block()); - } - - @Test - void build_shouldCreateRestTemplateWithSslConfiguration() { - when(publisherConfiguration.enableDmaapCertAuth()).thenReturn(true); - when(publisherConfiguration.keyStorePath()).thenReturn(getPath(KEY_STORE)); - when(publisherConfiguration.keyStorePasswordPath()).thenReturn(getPath(KEYSTORE_PASSWORD)); - when(publisherConfiguration.trustStorePath()).thenReturn(getPath(TRUST_STORE)); - when(publisherConfiguration.trustStorePasswordPath()).thenReturn(getPath(TRUSTSTORE_PASSWORD)); - - Assertions.assertNotNull(factory.build(publisherConfiguration).block()); - } - - private String getPath(String fileName) { - return this.getClass().getClassLoader().getResource(fileName).getPath(); - } -}
\ No newline at end of file diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/PublisherReactiveHttpClientFactoryTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/PublisherReactiveHttpClientFactoryTest.java deleted file mode 100644 index 764d5788..00000000 --- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/PublisherReactiveHttpClientFactoryTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.services.prh.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.prh.config.DmaapPublisherConfiguration; - - -class PublisherReactiveHttpClientFactoryTest { - - private DmaaPRestTemplateFactory restTemplateFactory = mock(DmaaPRestTemplateFactory.class); - private DmaapPublisherConfiguration dmaapPublisherConfiguration = mock(DmaapPublisherConfiguration.class); - private PublisherReactiveHttpClientFactory httpClientFactory = - new PublisherReactiveHttpClientFactory(restTemplateFactory); - - @Test - void create_shouldReturnNotNullFactoryInstance() { - Assertions.assertNotNull(httpClientFactory.create(dmaapPublisherConfiguration)); - } -}
\ No newline at end of file diff --git a/prh-dmaap-client/src/test/resources/keystore.password b/prh-dmaap-client/src/test/resources/keystore.password deleted file mode 100644 index 39823872..00000000 --- a/prh-dmaap-client/src/test/resources/keystore.password +++ /dev/null @@ -1 +0,0 @@ -mYHC98!qX}7h?W}jRv}MIXTJ
\ No newline at end of file diff --git a/prh-dmaap-client/src/test/resources/logback-test.xml b/prh-dmaap-client/src/test/resources/logback-test.xml deleted file mode 100644 index c1f00665..00000000 --- a/prh-dmaap-client/src/test/resources/logback-test.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ ===============================LICENSE_START====================================== - ~ Copyright © 2017 AT&T 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=========================================== - --> -<configuration> - <root level="OFF"/> -</configuration> diff --git a/prh-dmaap-client/src/test/resources/org.onap.dcae.jks b/prh-dmaap-client/src/test/resources/org.onap.dcae.jks Binary files differdeleted file mode 100644 index e74ce64f..00000000 --- a/prh-dmaap-client/src/test/resources/org.onap.dcae.jks +++ /dev/null diff --git a/prh-dmaap-client/src/test/resources/org.onap.dcae.trust.jks b/prh-dmaap-client/src/test/resources/org.onap.dcae.trust.jks Binary files differdeleted file mode 100644 index 10103cfb..00000000 --- a/prh-dmaap-client/src/test/resources/org.onap.dcae.trust.jks +++ /dev/null diff --git a/prh-dmaap-client/src/test/resources/truststore.password b/prh-dmaap-client/src/test/resources/truststore.password deleted file mode 100644 index 168e64bd..00000000 --- a/prh-dmaap-client/src/test/resources/truststore.password +++ /dev/null @@ -1 +0,0 @@ -*TQH?Lnszprs4LmlAj38yds(
\ No newline at end of file |