aboutsummaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/test/java/org
diff options
context:
space:
mode:
authorwasala <przemyslaw.wasala@nokia.com>2018-07-05 14:23:36 +0200
committerwasala <przemyslaw.wasala@nokia.com>2018-08-07 09:52:51 +0200
commite74228673c9c5241a9e901726716f77aacb2711f (patch)
treed4d9b2a4d85d984ce44b3f146a201416bf8b0343 /prh-app-server/src/test/java/org
parenta44fb6f1b9d72ec553ba23038db299b2b8a2016f (diff)
Bug fixes
Improve UnitTest Add changes after review in DmaaPReactiveTasks workflow Change-Id: I920092235528964758014c2d9d229ccd22e69cae Issue-ID: DCAEGEN2-563 Signed-off-by: wasala <przemyslaw.wasala@nokia.com>
Diffstat (limited to 'prh-app-server/src/test/java/org')
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParserTest.java8
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java5
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java12
3 files changed, 13 insertions, 12 deletions
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParserTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParserTest.java
index 9e7edc4d..32f5c1e2 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParserTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParserTest.java
@@ -180,7 +180,7 @@ class DmaapConsumerJsonParserTest {
Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
.when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(message)))
- .expectSubscription().expectError(DmaapNotFoundException.class);
+ .expectSubscription().expectError(DmaapNotFoundException.class).verify();
}
@@ -202,7 +202,7 @@ class DmaapConsumerJsonParserTest {
+ ":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":\"<<SerialNumber>>\","
+ "\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\":3}}}]";
StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(incorrectMessage)))
- .expectSubscription().expectError(DmaapNotFoundException.class);
+ .expectSubscription().expectError(DmaapNotFoundException.class).verify();
}
@Test
@@ -232,7 +232,7 @@ class DmaapConsumerJsonParserTest {
+ "\"pnfType\":\"AirScale\"}}}]";
StepVerifier
.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(jsonWithoutPnfVendorAndSerialNumber)))
- .expectSubscription().expectError(DmaapNotFoundException.class);
+ .expectSubscription().expectError(DmaapNotFoundException.class).verify();
}
@Test
@@ -260,6 +260,6 @@ class DmaapConsumerJsonParserTest {
+ "\"AJ02\",\"pnfSerialNumber\":\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":\"AirScale\","
+ "\"pnfVendorName\":\"Nokia\"}}}]";
StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(jsonWithoutIPInformation)))
- .expectSubscription().expectError(DmaapNotFoundException.class);
+ .expectSubscription().expectError(DmaapNotFoundException.class).verify();
}
}
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java
index c5a9d85a..b903fc90 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java
@@ -19,6 +19,7 @@
*/
package org.onap.dcaegen2.services.prh.tasks;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -98,7 +99,7 @@ class DmaapConsumerTaskImplTest {
//then
StepVerifier.create(dmaapConsumerTask.execute("Sample input")).expectSubscription()
- .expectError(DmaapEmptyResponseException.class);
+ .expectError(DmaapEmptyResponseException.class).verify();
verify(dMaaPConsumerReactiveHttpClient, times(1)).getDMaaPConsumerResponse();
}
@@ -112,7 +113,7 @@ class DmaapConsumerTaskImplTest {
//then
verify(dMaaPConsumerReactiveHttpClient, times(1)).getDMaaPConsumerResponse();
- Assertions.assertEquals(consumerDmaapModel, response.block());
+ assertEquals(consumerDmaapModel, response.block());
}
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java
index 6b08be55..25d1fff6 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java
@@ -19,6 +19,7 @@
*/
package org.onap.dcaegen2.services.prh.tasks;
+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;
@@ -28,7 +29,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
@@ -77,8 +77,7 @@ class DmaapPublisherTaskImplTest {
Executable executableFunction = () -> dmaapPublisherTask.execute(null);
//then
- Assertions
- .assertThrows(PrhTaskException.class, executableFunction, "The specified parameter is incorrect");
+ assertThrows(PrhTaskException.class, executableFunction, "The specified parameter is incorrect");
}
@Test
@@ -88,7 +87,7 @@ class DmaapPublisherTaskImplTest {
//when
StepVerifier.create(dmaapPublisherTask.execute(Mono.just(consumerDmaapModel))).expectSubscription()
- .expectNext(HttpStatus.OK.value());
+ .expectNext(HttpStatus.OK.toString()).verifyComplete();
//then
verify(dMaaPProducerReactiveHttpClient, times(1))
@@ -96,6 +95,7 @@ class DmaapPublisherTaskImplTest {
verifyNoMoreInteractions(dMaaPProducerReactiveHttpClient);
}
+
@Test
public void whenPassedObjectFits_butIncorrectResponseReturns() throws DmaapNotFoundException {
//given
@@ -103,7 +103,7 @@ class DmaapPublisherTaskImplTest {
//when
StepVerifier.create(dmaapPublisherTask.execute(Mono.just(consumerDmaapModel))).expectSubscription()
- .expectError(PrhTaskException.class);
+ .expectNext(String.valueOf(HttpStatus.UNAUTHORIZED.value())).verifyComplete();
//then
verify(dMaaPProducerReactiveHttpClient, times(1)).getDMaaPProducerResponse(any(Mono.class));
@@ -114,7 +114,7 @@ class DmaapPublisherTaskImplTest {
private void prepareMocksForTests(Integer httpResponseCode) {
dMaaPProducerReactiveHttpClient = mock(DMaaPProducerReactiveHttpClient.class);
when(dMaaPProducerReactiveHttpClient.getDMaaPProducerResponse(any(Mono.class)))
- .thenReturn(Mono.just(httpResponseCode));
+ .thenReturn(Mono.just(httpResponseCode.toString()));
dmaapPublisherTask = spy(new DmaapPublisherTaskImpl(appConfig));
when(dmaapPublisherTask.resolveConfiguration()).thenReturn(dmaapPublisherConfiguration);
doReturn(dMaaPProducerReactiveHttpClient).when(dmaapPublisherTask).resolveClient();