diff options
author | 2018-11-05 16:04:54 +0100 | |
---|---|---|
committer | 2018-11-05 16:10:17 +0100 | |
commit | e8a80102a45458b3f1d15e07dc0a63e1370c44a7 (patch) | |
tree | 374b4fc2d3b7577da8612ab92998f0e25090f147 /prh-dmaap-client/src/test | |
parent | 600c05b1530c120b34370e86e92dfd79421474fe (diff) |
DmaaP Publisher and consumer interfaces ssl setup
Change-Id: I971d0fb222c6e8e15de4fc4a4d9eeb4ef3a99f44
Issue-ID: DCAEGEN2-944
Signed-off-by: piotr.karas <piotr.karas@nokia.com>
Diffstat (limited to 'prh-dmaap-client/src/test')
-rw-r--r-- | prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/ConsumerReactiveHttpClientFactoryTest.java | 42 | ||||
-rw-r--r-- | prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java | 3 | ||||
-rw-r--r-- | prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPReactiveWebClientTest.java (renamed from prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClientTest.java) | 2 | ||||
-rw-r--r-- | prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPPublisherReactiveHttpClientTest.java | 17 | ||||
-rw-r--r-- | prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/PublisherReactiveHttpClientFactoryTest.java | 39 |
5 files changed, 90 insertions, 13 deletions
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 new file mode 100644 index 00000000..6e864432 --- /dev/null +++ b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/ConsumerReactiveHttpClientFactoryTest.java @@ -0,0 +1,42 @@ +/* + * ============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 DMaaPReactiveWebClient reactiveWebClient = mock(DMaaPReactiveWebClient.class); + private ConsumerReactiveHttpClientFactory httpClientFactory = + new ConsumerReactiveHttpClientFactory(reactiveWebClient); + + @Test + void create_shouldReturnNotNullFactoryInstance() { + Assertions.assertNotNull(httpClientFactory.create(dmaapConsumerConfiguration)); + verify(reactiveWebClient).build(); + } +}
\ 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 index c8ffd12f..595fd6d4 100644 --- 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 @@ -66,12 +66,12 @@ class DMaaPConsumerReactiveHttpClientTest { when(consumerConfigurationMock.consumerGroup()).thenReturn("OpenDCAE-c12"); when(consumerConfigurationMock.consumerId()).thenReturn("c12"); - dmaapConsumerReactiveHttpClient = new DMaaPConsumerReactiveHttpClient(consumerConfigurationMock); 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); } @@ -85,7 +85,6 @@ class DMaaPConsumerReactiveHttpClientTest { //when mockDependantObjects(); doReturn(expectedResult).when(responseSpec).bodyToMono(String.class); - dmaapConsumerReactiveHttpClient.createDMaaPWebClient(webClient); Mono<String> response = dmaapConsumerReactiveHttpClient.getDMaaPConsumerResponse(); //then diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClientTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPReactiveWebClientTest.java index 4ca5ceb6..6b06c06a 100644 --- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClientTest.java +++ b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPReactiveWebClientTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.dcaegen2.services.prh.service; +package org.onap.dcaegen2.services.prh.service.consumer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; 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 index db3d515c..ce2f7f36 100644 --- 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 @@ -39,8 +39,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.client.RestTemplate; import reactor.test.StepVerifier; - - /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 7/4/18 */ @@ -48,10 +46,10 @@ import reactor.test.StepVerifier; class DMaaPPublisherReactiveHttpClientTest { private DMaaPPublisherReactiveHttpClient dmaapPublisherReactiveHttpClient; - private DmaapPublisherConfiguration dmaapPublisherConfigurationMock = mock( - DmaapPublisherConfiguration.class); + DmaapPublisherConfiguration.class); private ConsumerDmaapModel consumerDmaapModel = new ConsumerDmaapModelForUnitTest(); + private RestTemplate restTemplate = mock(RestTemplate.class); @BeforeEach @@ -63,7 +61,8 @@ class DMaaPPublisherReactiveHttpClientTest { when(dmaapPublisherConfigurationMock.dmaapUserPassword()).thenReturn("PRH"); when(dmaapPublisherConfigurationMock.dmaapContentType()).thenReturn("application/json"); when(dmaapPublisherConfigurationMock.dmaapTopicName()).thenReturn("unauthenticated.PNF_READY"); - dmaapPublisherReactiveHttpClient = new DMaaPPublisherReactiveHttpClient(dmaapPublisherConfigurationMock); + dmaapPublisherReactiveHttpClient = + new DMaaPPublisherReactiveHttpClient(dmaapPublisherConfigurationMock, restTemplate); } @@ -72,21 +71,19 @@ class DMaaPPublisherReactiveHttpClientTest { //given int responseSuccess = 200; ResponseEntity<String> mockedResponseEntity = mock(ResponseEntity.class); - RestTemplate restTemplate = mock(RestTemplate.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()); - dmaapPublisherReactiveHttpClient.createDMaaPWebClient(restTemplate); + .exchange(any(URI.class), any(HttpMethod.class), any(HttpEntity.class), (Class<Object>) any()); //then StepVerifier.create(dmaapPublisherReactiveHttpClient.getDMaaPProducerResponse(consumerDmaapModel)) - .expectSubscription().expectNext(mockedResponseEntity).verifyComplete(); + .expectSubscription().expectNext(mockedResponseEntity).verifyComplete(); } @Test void getAppropriateUri_whenPassingCorrectedPathForPnf() { Assertions.assertEquals(dmaapPublisherReactiveHttpClient.getUri(), - URI.create("https://54.45.33.2:1234/unauthenticated.PNF_READY")); + 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/PublisherReactiveHttpClientFactoryTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/PublisherReactiveHttpClientFactoryTest.java new file mode 100644 index 00000000..3acfde9d --- /dev/null +++ b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/PublisherReactiveHttpClientFactoryTest.java @@ -0,0 +1,39 @@ +/* + * ============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 DmaapPublisherConfiguration dmaapPublisherConfiguration = mock(DmaapPublisherConfiguration.class); + private PublisherReactiveHttpClientFactory httpClientFactory = new PublisherReactiveHttpClientFactory(); + + @Test + void create_shouldReturnNotNullFactoryInstance() { + Assertions.assertNotNull(httpClientFactory.create(dmaapPublisherConfiguration)); + } +}
\ No newline at end of file |