aboutsummaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/HttpGetClientTest.java
diff options
context:
space:
mode:
authorwasala <przemyslaw.wasala@nokia.com>2018-09-11 09:50:21 +0200
committerwasala <przemyslaw.wasala@nokia.com>2018-09-11 19:51:20 +0200
commit4a1457c84c5f3a68ccdfb3e348996e14ccea89e8 (patch)
treecf83bbe8b29dfc720fe2fafa94b3b84d6c3a7379 /prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/HttpGetClientTest.java
parentfea7d735b49c4be0958c6531771cc2ee511db490 (diff)
PRH:security vulnerabilities fix
*Removed unused libraries *Fixed vulnerablities in connection with clm scan *Replaced AssertJ in tests verification by using StepVerifier Change-Id: I81c3ac54e5514735f0fca8150fcc218d96dc5ce3 Issue-ID: DCAEGEN2-770 Signed-off-by: wasala <przemyslaw.wasala@nokia.com>
Diffstat (limited to 'prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/HttpGetClientTest.java')
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/HttpGetClientTest.java23
1 files changed, 8 insertions, 15 deletions
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/HttpGetClientTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/HttpGetClientTest.java
index 20fbc6bf..ab789a00 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/HttpGetClientTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/HttpGetClientTest.java
@@ -21,8 +21,6 @@
package org.onap.dcaegen2.services.prh.service;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -34,6 +32,8 @@ import com.google.gson.JsonSyntaxException;
import org.junit.jupiter.api.Test;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
+import reactor.test.StepVerifier;
+
class HttpGetClientTest {
private static final String SOMEURL = "http://someurl";
@@ -50,12 +50,9 @@ class HttpGetClientTest {
HttpGetClient httpGetClient = new HttpGetClient(webClient);
when(responseSpec.bodyToMono(String.class)).thenReturn(Mono.just(DATA));
- //when
- Mono<JsonObject> jsonObjectMono = httpGetClient.callHttpGet(SOMEURL, JsonObject.class);
-
- //then
- assertThat(jsonObjectMono).isNotNull();
- assertThat(jsonObjectMono.block()).isEqualTo(gson.fromJson(DATA, JsonObject.class));
+ //when/then
+ StepVerifier.create(httpGetClient.callHttpGet(SOMEURL, JsonObject.class)).expectSubscription()
+ .expectNext(gson.fromJson(DATA, JsonObject.class)).verifyComplete();
}
@Test
@@ -65,16 +62,12 @@ class HttpGetClientTest {
HttpGetClient httpGetClient = new HttpGetClient(webClient);
when(responseSpec.bodyToMono(String.class)).thenReturn(Mono.just("some wrong data"));
- //when
- Mono<JsonObject> jsonObjectMono = httpGetClient.callHttpGet(SOMEURL, JsonObject.class);
-
- //then
- assertThat(jsonObjectMono).isNotNull();
- assertThrows(JsonSyntaxException.class, jsonObjectMono::block);
+ //when/then
+ StepVerifier.create(httpGetClient.callHttpGet(SOMEURL, JsonObject.class)).expectSubscription()
+ .expectError(JsonSyntaxException.class).verify();
}
-
private void mockWebClientDependantObject() {
doReturn(requestBodyUriSpec).when(webClient).get();
when(requestBodyUriSpec.uri(SOMEURL)).thenReturn(requestBodyUriSpec);