aboutsummaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'prh-app-server/src/test/java')
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/HttpGetClientTest.java23
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProviderTest.java21
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java4
3 files changed, 18 insertions, 30 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);
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProviderTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProviderTest.java
index 7b305222..e99389f5 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProviderTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProviderTest.java
@@ -20,18 +20,17 @@
package org.onap.dcaegen2.services.prh.service;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.services.prh.model.EnvProperties;
import org.onap.dcaegen2.services.prh.model.ImmutableEnvProperties;
import reactor.core.publisher.Mono;
+import reactor.test.StepVerifier;
class PrhConfigurationProviderTest {
@@ -72,12 +71,9 @@ class PrhConfigurationProviderTest {
PrhConfigurationProvider provider = new PrhConfigurationProvider(webClient);
- // when
- Mono<JsonObject> jsonObjectMono = provider.callForPrhConfiguration(envProperties);
-
- // then
- assertThat(jsonObjectMono).isNotNull();
- assertThat(jsonObjectMono.block()).isEqualTo(prhMockConfigurationJson);
+ //when/then
+ StepVerifier.create(provider.callForPrhConfiguration(envProperties)).expectSubscription()
+ .expectNext(prhMockConfigurationJson).verifyComplete();
}
@Test
@@ -90,11 +86,8 @@ class PrhConfigurationProviderTest {
PrhConfigurationProvider provider = new PrhConfigurationProvider(webClient);
- // when
- Mono<JsonObject> jsonObjectMono = provider.callForPrhConfiguration(envProperties);
-
- // then
- assertThat(jsonObjectMono).isNotNull();
- Assertions.assertThrows(IllegalStateException.class, jsonObjectMono::block);
+ //when/then
+ StepVerifier.create(provider.callForPrhConfiguration(envProperties)).expectSubscription()
+ .expectError(IllegalStateException.class).verify();
}
} \ No newline at end of file
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java
index 5aa63e00..2f7ff61c 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java
@@ -23,6 +23,7 @@ package org.onap.dcaegen2.services.prh.tasks;
import static org.mockito.Mockito.spy;
import java.util.Map;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -49,6 +50,7 @@ public class ScheduleControllerSpy {
@Bean
@Primary
public ScheduledTasks registerSimpleScheduledTask() {
- return spy(new ScheduledTasks(dmaapConsumerTaskImplSpy, dmaapPublisherTaskImplSpy, aaiPublisherTaskImplSpy, mdcContextMap));
+ return spy(new ScheduledTasks(dmaapConsumerTaskImplSpy, dmaapPublisherTaskImplSpy, aaiPublisherTaskImplSpy,
+ mdcContextMap));
}
}