Fix DmaapConsumerJsonParserTest

Change-Id: I4fd1092608c3f75e60e0495caf5753dec7c0703a
Issue-ID: DCAEGEN2-1312
Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
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 e065fc7..cdcef07 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
@@ -245,6 +245,70 @@
     }
 
     @Test
+    void whenPassingCorrectJsonWithoutIpv4andIpv6_validationNotThrowingAnException() {
+        //given
+        String message = "[{\"event\": {"
+            + "\"commonEventHeader\": { "
+            + " \"sourceName\":\"NOKQTFCOC540002E\","
+            + " \"nfNamingCode\":\"gNB\" "
+            + "},"
+            + "\"pnfRegistrationFields\": {"
+            + " \"vendorName\": \"nokia\","
+            + " \"serialNumber\": \"QTFCOC540002E\","
+            + " \"pnfRegistrationFieldsVersion\": \"2.0\","
+            + " \"modelNumber\": \"3310\","
+            + " \"unitType\": \"type\",\n"
+            + " \"unitFamily\": \"BBU\","
+            + " \"softwareVersion\": \"v4.5.0.1\","
+            + " \"additionalFields\": {}"
+            + "}}}]";
+
+        String parsed = "{\"event\": {"
+            + "\"commonEventHeader\": { "
+            + " \"sourceName\":\"NOKQTFCOC540002E\","
+            + " \"nfNamingCode\":\"gNB\" "
+            + "},"
+            + "\"pnfRegistrationFields\": {"
+            + " \"vendorName\": \"nokia\","
+            + " \"serialNumber\": \"QTFCOC540002E\","
+            + " \"pnfRegistrationFieldsVersion\": \"2.0\","
+            + " \"modelNumber\": \"3310\","
+            + " \"unitType\": \"type\",\n"
+            + " \"unitFamily\": \"BBU\","
+            + " \"softwareVersion\": \"v4.5.0.1\","
+            + " \"additionalFields\": {}"
+            + "}}}";
+
+        ConsumerDmaapModel expectedObject = ImmutableConsumerDmaapModel.builder()
+            .correlationId("NOKQTFCOC540002E")
+            .serialNumber("QTFCOC540002E")
+            .ipv4("")
+            .ipv6("")
+            .equipVendor("nokia")
+            .equipModel("3310")
+            .equipType("type")
+            .nfRole("gNB")
+            .swVersion("v4.5.0.1")
+            .additionalFields(new JsonObject())
+            .build();
+
+        JsonArray messageAsJsonArray = (JsonArray) jsonParser.parse(message);
+
+        //when
+        DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
+        JsonElement jsonElement = jsonParser.parse(parsed);
+        Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
+            .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
+
+        ConsumerDmaapModel consumerDmaapModel = dmaapConsumerJsonParser
+            .getJsonObject(Mono.just((messageAsJsonArray))).blockFirst();
+        //then
+        Assertions.assertNotNull(consumerDmaapModel);
+        Assertions.assertEquals(expectedObject, consumerDmaapModel);
+    }
+
+
+    @Test
     void whenPassingJsonWithoutMandatoryHeaderInformation_validationAddingAnException() {
         String parsed = "{\"event\": {"
             + "\"commonEventHeader\": {},"
@@ -512,101 +576,6 @@
     }
 
     @Test
-    void whenPassingCorrectJsonWithoutIpv4andIpv6_validationAddingAnException() {
-        //given
-        String message = "[{\"event\": {"
-            + "\"commonEventHeader\": { "
-            + " \"sourceName\":\"NOKQTFCOC540002E\","
-            + " \"nfNamingCode\":\"gNB\" "
-            + "},"
-            + "\"pnfRegistrationFields\": {"
-            + " \"vendorName\": \"nokia\","
-            + " \"serialNumber\": \"QTFCOC540002E\","
-            + " \"pnfRegistrationFieldsVersion\": \"2.0\","
-            + " \"modelNumber\": \"3310\","
-            + " \"unitType\": \"type\",\n"
-            + " \"unitFamily\": \"BBU\","
-            + " \"softwareVersion\": \"v4.5.0.1\","
-            + " \"additionalFields\": {}"
-            + "}}}]";
-
-        String parsed = "{\"event\": {"
-            + "\"commonEventHeader\": { "
-            + " \"sourceName\":\"NOKQTFCOC540002E\","
-            + " \"nfNamingCode\":\"gNB\" "
-            + "},"
-            + "\"pnfRegistrationFields\": {"
-            + " \"vendorName\": \"nokia\","
-            + " \"serialNumber\": \"QTFCOC540002E\","
-            + " \"pnfRegistrationFieldsVersion\": \"2.0\","
-            + " \"modelNumber\": \"3310\","
-            + " \"unitType\": \"type\",\n"
-            + " \"unitFamily\": \"BBU\","
-            + " \"softwareVersion\": \"v4.5.0.1\","
-            + " \"additionalFields\": {}"
-            + "}}}";
-
-        JsonArray messageAsJsonArray = (JsonArray) jsonParser.parse(message);
-
-        DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
-        JsonElement jsonElement = jsonParser.parse(parsed);
-        Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
-            .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
-
-        StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(messageAsJsonArray)))
-            .expectSubscription().thenRequest(1).verifyComplete();
-
-    }
-
-    @Test
-    void whenPassingJsonWithoutIpInformation_validationAddingAnException() {
-        String parsed =
-            "{\"event\": {"
-                + "\"commonEventHeader\": {\"sourceName\": \"NOKQTFCOC540002E\"},"
-                + "\"pnfRegistrationFields\": {"
-                + " \"unitType\": \"AirScale\","
-                + " \"serialNumber\": \"QTFCOC540002E\","
-                + " \"pnfRegistrationFieldsVersion\": \"2.0\","
-                + " \"manufactureDate\": \"1535014037024\","
-                + " \"modelNumber\": \"7BEA\",\n"
-                + " \"lastServiceDate\": \"1535014037024\","
-                + " \"unitFamily\": \"BBU\","
-                + " \"vendorName\": \"Nokia\","
-                + " \"softwareVersion\": \"v4.5.0.1\","
-                + " \"oamV4IpAddress\": \"\","
-                + " \"oamV6IpAddress\": \"\","
-                + " \"additionalFields\": {}"
-                + "}}}";
-
-        DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
-        JsonElement jsonElement = jsonParser.parse(parsed);
-        Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
-            .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
-        String jsonWithoutIpInformation =
-            "[{\"event\": {"
-                + "\"commonEventHeader\": {\"sourceName\": \"NOKQTFCOC540002E\"},"
-                + "\"pnfRegistrationFields\": {"
-                + " \"unitType\": \"AirScale\","
-                + " \"serialNumber\": \"QTFCOC540002E\","
-                + " \"pnfRegistrationFieldsVersion\": \"2.0\","
-                + " \"manufactureDate\": \"1535014037024\","
-                + " \"modelNumber\": \"7BEA\",\n"
-                + " \"lastServiceDate\": \"1535014037024\","
-                + " \"unitFamily\": \"BBU\","
-                + " \"vendorName\": \"Nokia\","
-                + " \"softwareVersion\": \"v4.5.0.1\","
-                + " \"oamV4IpAddress\": \"\","
-                + " \"oamV6IpAddress\": \"\","
-                + " \"additionalFields\": {}"
-                + "}}}]";
-
-        JsonArray jsonWithoutOpInformationAsJsonArray = (JsonArray) jsonParser.parse(jsonWithoutIpInformation);
-
-        StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(jsonWithoutOpInformationAsJsonArray)))
-            .expectSubscription().thenRequest(1).verifyComplete();
-    }
-
-    @Test
     void whenPassingCorrectJsoArrayWithoutIpv4_validationNotThrowingAnException() {
         //given
         String message = "[{\"event\": {"