aboutsummaryrefslogtreecommitdiffstats
path: root/datafile-dmaap-client/src/test/java/org/onap
diff options
context:
space:
mode:
authorelinuxhenrik <henrik.b.andersson@est.tech>2018-09-19 08:49:28 +0200
committerelinuxhenrik <henrik.b.andersson@est.tech>2018-09-21 16:46:38 +0200
commit90b9931873e13247e937a6d4b5206c65033b306e (patch)
tree23e667e9d68958edc49a94bb5a02778a6cc45713 /datafile-dmaap-client/src/test/java/org/onap
parent3468d474187ef01546bdf1180d11453a4f924d31 (diff)
Use correct Content Type from DMaaP
Add the Content Type to the header the DMaaP consumer uses to get the fileReady event from DMAaaP to prevent formatting problems. Change-Id: Iedf38b7542e5709a78f383d31c75e7b95aa56cfe Issue-ID: DCAEGEN2-825 Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
Diffstat (limited to 'datafile-dmaap-client/src/test/java/org/onap')
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClientTest.java34
1 files changed, 14 insertions, 20 deletions
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClientTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClientTest.java
index 4f96a903..4568bdde 100644
--- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClientTest.java
+++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClientTest.java
@@ -51,8 +51,8 @@ class DmaapConsumerReactiveHttpClientTest {
private static final String JSON_MESSAGE = "{ \"responseFromDmaap\": \"Success\"}";
private Mono<String> expectedResult = Mono.empty();
private WebClient webClient;
- private RequestHeadersUriSpec requestHeadersSpec;
- private ResponseSpec responseSpec;
+ private RequestHeadersUriSpec requestHeadersSpecMock;
+ private ResponseSpec responseSpecMock;
@BeforeEach
@@ -73,8 +73,8 @@ class DmaapConsumerReactiveHttpClientTest {
.filter(basicAuthentication(consumerConfigurationMock.dmaapUserName(),
consumerConfigurationMock.dmaapUserPassword()))
.build());
- requestHeadersSpec = mock(RequestHeadersUriSpec.class);
- responseSpec = mock(ResponseSpec.class);
+ requestHeadersSpecMock = mock(RequestHeadersUriSpec.class);
+ responseSpecMock = mock(ResponseSpec.class);
}
@@ -85,8 +85,9 @@ class DmaapConsumerReactiveHttpClientTest {
//when
mockDependantObjects();
- doReturn(expectedResult).when(responseSpec).bodyToMono(String.class);
+ doReturn(expectedResult).when(responseSpecMock).bodyToMono(String.class);
dmaapConsumerReactiveHttpClient.createDmaapWebClient(webClient);
+
Mono<String> response = dmaapConsumerReactiveHttpClient.getDmaapConsumerResponse();
//then
@@ -98,24 +99,17 @@ class DmaapConsumerReactiveHttpClientTest {
}
@Test
- void getHttpResponse_whenUriSyntaxExceptionHasBeenThrown() throws URISyntaxException {
- //given
- dmaapConsumerReactiveHttpClient = spy(dmaapConsumerReactiveHttpClient);
- //when
- when(webClient.get()).thenReturn(requestHeadersSpec);
- dmaapConsumerReactiveHttpClient.createDmaapWebClient(webClient);
- when(dmaapConsumerReactiveHttpClient.getUri()).thenThrow(URISyntaxException.class);
-
- //then
- StepVerifier.create(dmaapConsumerReactiveHttpClient.getDmaapConsumerResponse()).expectSubscription()
- .expectError(Exception.class).verify();
+ void getAppropriateUri_whenPassingCorrectedUriData() throws URISyntaxException {
+ Assertions.assertEquals(dmaapConsumerReactiveHttpClient.getUri(),
+ URI.create("https://54.45.33.2:1234/unauthenticated.VES_NOTIFICATION_OUTPUT/OpenDCAE-c12/c12"));
}
private void mockDependantObjects() {
- when(webClient.get()).thenReturn(requestHeadersSpec);
- when(requestHeadersSpec.uri((URI) any())).thenReturn(requestHeadersSpec);
- when(requestHeadersSpec.retrieve()).thenReturn(responseSpec);
- doReturn(responseSpec).when(responseSpec).onStatus(any(), any());
+ when(webClient.get()).thenReturn(requestHeadersSpecMock);
+ when(requestHeadersSpecMock.uri((URI) any())).thenReturn(requestHeadersSpecMock);
+ when(requestHeadersSpecMock.headers(any())).thenReturn(requestHeadersSpecMock);
+ when(requestHeadersSpecMock.retrieve()).thenReturn(responseSpecMock);
+ doReturn(responseSpecMock).when(responseSpecMock).onStatus(any(), any());
}
} \ No newline at end of file