Align to new SDK version

Change-Id: I06974c7f890bfa1cb875d776efa8b3a9f5b0a711
Issue-ID: DCAEGEN2-1613
Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java
index c059d34..11939b5 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java
@@ -20,10 +20,10 @@
 
 package org.onap.dcaegen2.services.prh.service;
 
-import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
+import io.vavr.collection.List;
 import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException;
 import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
 import org.onap.dcaegen2.services.prh.model.ImmutableConsumerDmaapModel;
@@ -85,7 +85,7 @@
         return monoMessage.flatMapMany(msgRouterResponse -> getConsumerDmaapModelFromJsonArray(msgRouterResponse.items()));
     }
 
-    private Flux<ConsumerDmaapModel> getConsumerDmaapModelFromJsonArray(JsonArray items) {
+    private Flux<ConsumerDmaapModel> getConsumerDmaapModelFromJsonArray(List<JsonElement> items) {
         LOGGER.debug("DmaapConsumerJsonParser input for parsing: {}", items);
 
         if (items.size() == 0) {
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
index af5b250..a990e50 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
@@ -50,8 +50,7 @@
     public Flux<ConsumerDmaapModel> execute() {
         MessageRouterSubscriber messageRouterSubscriber = config.getMessageRouterSubscriber();
         MessageRouterSubscribeRequest messageRouterSubscribeRequest = config.getMessageRouterSubscribeRequest();
-        Mono<MessageRouterSubscribeResponse> response = messageRouterSubscriber
-                .get(messageRouterSubscribeRequest);
+        Mono<MessageRouterSubscribeResponse> response = messageRouterSubscriber.get(messageRouterSubscribeRequest);
         return dmaapConsumerJsonParser.getJsonObject(response);
     }
 
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 98b7314..342460e 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
@@ -20,10 +20,10 @@
 
 package org.onap.dcaegen2.services.prh.service;
 
-import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
+import io.vavr.collection.List;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
@@ -48,7 +48,7 @@
     @Test
     void whenPassingCorrectJson_validationNotThrowingAnException() {
         //given
-        String message = "[{\"event\": {"
+        String message = "{\"event\": {"
             + "\"commonEventHeader\": { "
             + " \"sourceName\":\"NOKQTFCOC540002E\","
             + " \"nfNamingCode\":\"gNB\" "
@@ -64,7 +64,7 @@
             + " \"softwareVersion\": \"v4.5.0.1\","
             + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\","
             + " \"additionalFields\": {\"attachmentPoint\":\"bla-bla-30-3\",\"cvlan\":\"678\",\"svlan\":\"1005\"}"
-            + "}}}]";
+            + "}}}";
 
         String parsed = "{\"event\": {"
             + "\"commonEventHeader\": { "
@@ -103,8 +103,8 @@
             .additionalFields(jsonObject)
             .build();
 
-        JsonArray messageAsJsonArray = (JsonArray) jsonParser.parse(message);
-        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonArray).build();
+        List<JsonElement> messageAsJsonElementList = List.of(message).map(jsonParser::parse);
+        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonElementList).build();
 
         //when
         DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
@@ -122,7 +122,7 @@
     @Test
     void whenPassingJsonWithoutAdditionalFields_validationNotThrowingAnException() {
         //given
-        String message = "[{\"event\": {"
+        String message = "{\"event\": {"
             + "\"commonEventHeader\": { "
             + " \"sourceName\":\"NOKQTFCOC540002E\","
             + " \"nfNamingCode\":\"gNB\" "
@@ -137,7 +137,7 @@
             + " \"oamV4IpAddress\": \"10.16.123.234\","
             + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\","
             + " \"softwareVersion\": \"v4.5.0.1\""
-            + "}}}]";
+            + "}}}";
 
         String parsed = "{\"event\": {"
             + "\"commonEventHeader\": { "
@@ -167,8 +167,8 @@
             .nfRole("gNB")
             .swVersion("v4.5.0.1")
             .build();
-        JsonArray messageAsJsonArray = (JsonArray) jsonParser.parse(message);
-        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonArray).build();
+        List<JsonElement> messageAsJsonElementList = List.of(message).map(jsonParser::parse);
+        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonElementList).build();
         //when
         DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
         JsonElement jsonElement = new JsonParser().parse(parsed);
@@ -184,7 +184,7 @@
     @Test
     void whenPassingJsonWithEmptyAdditionalFields_validationNotThrowingAnException() {
         //given
-        String message = "[{\"event\": {"
+        String message = "{\"event\": {"
             + "\"commonEventHeader\": { "
             + " \"sourceName\":\"NOKQTFCOC540002E\","
             + " \"nfNamingCode\":\"gNB\" "
@@ -200,7 +200,7 @@
             + " \"oamV4IpAddress\": \"10.16.123.234\","
             + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\","
             + " \"additionalFields\": {}"
-            + "}}}]";
+            + "}}}";
 
         String parsed = "{\"event\": {"
             + "\"commonEventHeader\": { "
@@ -233,8 +233,8 @@
             .additionalFields(new JsonObject())
             .build();
 
-        JsonArray messageAsJsonArray = (JsonArray) jsonParser.parse(message);
-        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonArray).build();
+        List<JsonElement> messageAsJsonElementList = List.of(message).map(jsonParser::parse);
+        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonElementList).build();
 
         //when
         DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
@@ -252,7 +252,7 @@
     @Test
     void whenPassingCorrectJsonWithoutIpv4andIpv6_validationNotThrowingAnException() {
         //given
-        String message = "[{\"event\": {"
+        String message = "{\"event\": {"
             + "\"commonEventHeader\": { "
             + " \"sourceName\":\"NOKQTFCOC540002E\","
             + " \"nfNamingCode\":\"gNB\" "
@@ -266,7 +266,7 @@
             + " \"unitFamily\": \"BBU\","
             + " \"softwareVersion\": \"v4.5.0.1\","
             + " \"additionalFields\": {}"
-            + "}}}]";
+            + "}}}";
 
         String parsed = "{\"event\": {"
             + "\"commonEventHeader\": { "
@@ -297,8 +297,8 @@
             .additionalFields(new JsonObject())
             .build();
 
-        JsonArray messageAsJsonArray = (JsonArray) jsonParser.parse(message);
-        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonArray).build();
+        List<JsonElement> messageAsJsonElementList = List.of(message).map(jsonParser::parse);
+        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonElementList).build();
 
         //when
         DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
@@ -337,7 +337,7 @@
         JsonElement jsonElement = jsonParser.parse(parsed);
         Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
             .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
-        String incorrectMessage = "[{\"event\": {"
+        String incorrectMessage = "{\"event\": {"
             + "\"commonEventHeader\": {},"
             + "\"pnfRegistrationFields\": {"
             + " \"unitType\": \"AirScale\","
@@ -352,10 +352,10 @@
             + " \"oamV4IpAddress\": \"10.16.123.234\","
             + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\","
             + " \"additionalFields\": {}"
-            + "}}}]";
+            + "}}}";
 
-        JsonArray incorrectMessageAsJsonArray = (JsonArray) jsonParser.parse(incorrectMessage);
-        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(incorrectMessageAsJsonArray).build();
+        List<JsonElement> incorrectMessageAsJsonElementList = List.of(incorrectMessage).map(jsonParser::parse);
+        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(incorrectMessageAsJsonElementList).build();
 
         StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(response)))
             .expectSubscription().thenRequest(1).verifyComplete();
@@ -384,7 +384,7 @@
         Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
             .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
         String jsonWithoutSourceName =
-            "[{\"event\": {"
+            "{\"event\": {"
                 + "\"commonEventHeader\": {},"
                 + "\"pnfRegistrationFields\": {"
                 + " \"unitType\": \"AirScale\","
@@ -398,10 +398,10 @@
                 + " \"softwareVersion\": \"v4.5.0.1\","
                 + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\","
                 + " \"additionalFields\": {}"
-                + "}}}]";
+                + "}}}";
 
-        JsonArray jsonWithoutSourceNameAsJsonArray = (JsonArray) jsonParser.parse(jsonWithoutSourceName);
-        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(jsonWithoutSourceNameAsJsonArray).build();
+        List<JsonElement> jsonWithoutSourceNameAsJsonElementList = List.of(jsonWithoutSourceName).map(jsonParser::parse);
+        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(jsonWithoutSourceNameAsJsonElementList).build();
         StepVerifier
             .create(dmaapConsumerJsonParser.getJsonObject(Mono.just(response)))
             .expectSubscription().thenRequest(1)
@@ -434,7 +434,7 @@
         Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
             .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
         String jsonWithoutIpInformation =
-            "[{\"event\": {"
+            "{\"event\": {"
                 + "\"commonEventHeader\": {\"sourceName\": \"\"},"
                 + "\"pnfRegistrationFields\": {"
                 + " \"unitType\": \"AirScale\","
@@ -449,10 +449,10 @@
                 + " \"oamV4IpAddress\": \"10.16.123.234\","
                 + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\","
                 + " \"additionalFields\": {}"
-                + "}}}]";
+                + "}}}";
 
-        JsonArray jsonWithoutIpInformationAsJsonArray = (JsonArray) jsonParser.parse(jsonWithoutIpInformation);
-        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(jsonWithoutIpInformationAsJsonArray).build();
+        List<JsonElement> jsonWithoutIpInformationAsJsonElementList = List.of(jsonWithoutIpInformation).map(jsonParser::parse);
+        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(jsonWithoutIpInformationAsJsonElementList).build();
 
         StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(response)))
             .expectSubscription().thenRequest(1).verifyComplete();
@@ -461,7 +461,7 @@
     @Test
     void whenPassingCorrectJsonWithoutIpv4_validationNotThrowingAnException() {
         //given
-        String message = "[{\"event\": {"
+        String message = "{\"event\": {"
             + "\"commonEventHeader\": { "
             + " \"sourceName\":\"NOKQTFCOC540002E\","
             + " \"nfNamingCode\":\"gNB\" "
@@ -475,7 +475,7 @@
             + " \"unitFamily\": \"BBU\","
             + " \"softwareVersion\": \"v4.5.0.1\","
             + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\""
-            + "}}}]";
+            + "}}}";
 
         String parsed = "{\"event\": {"
             + "\"commonEventHeader\": { "
@@ -493,8 +493,8 @@
             + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\""
             + "}}}";
 
-        JsonArray messageAsJsonArray = (JsonArray) jsonParser.parse(message);
-        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonArray).build();
+        List<JsonElement> messageAsJsonElementList = List.of(message).map(jsonParser::parse);
+        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonElementList).build();
         //when
         DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
         JsonElement jsonElement = jsonParser.parse(parsed);
@@ -524,7 +524,7 @@
     @Test
     void whenPassingCorrectJsonWithoutIpv6_validationNotThrowingAnException() {
         //given
-        String message = "[{\"event\": {"
+        String message = "{\"event\": {"
             + "\"commonEventHeader\": { "
             + " \"sourceName\":\"NOKQTFCOC540002E\","
             + " \"nfNamingCode\":\"gNB\" "
@@ -538,7 +538,7 @@
             + " \"unitFamily\": \"BBU\","
             + " \"oamV4IpAddress\": \"10.16.123.234\","
             + " \"softwareVersion\": \"v4.5.0.1\""
-            + "}}}]";
+            + "}}}";
 
         String parsed = "{\"event\": {"
             + "\"commonEventHeader\": { "
@@ -568,8 +568,8 @@
             .swVersion("v4.5.0.1")
             .build();
 
-        JsonArray messageAsJsonArray = (JsonArray) jsonParser.parse(message);
-        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonArray).build();
+        List<JsonElement> messageAsJsonElementList = List.of(message).map(jsonParser::parse);
+        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonElementList).build();
 
         //when
         DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
@@ -586,7 +586,7 @@
     }
 
     @Test
-    void whenPassingCorrectJsoArrayWithoutIpv4_validationNotThrowingAnException() {
+    void whenPassingCorrectJsonArrayWithoutIpv4_validationNotThrowingAnException() {
         //given
         String message = "[{\"event\": {"
             + "\"commonEventHeader\": { "
@@ -634,8 +634,12 @@
             .additionalFields(new JsonObject())
             .build();
 
-        JsonArray messageAsJsonArray = (JsonArray) jsonParser.parse(message);
-        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonArray).build();
+        List<JsonElement> messageAsJsonElementList = List.empty();
+        for(JsonElement el : jsonParser.parse(message).getAsJsonArray()) {
+            messageAsJsonElementList = messageAsJsonElementList.append(el);
+        }
+
+        MessageRouterSubscribeResponse response = ImmutableMessageRouterSubscribeResponse.builder().items(messageAsJsonElementList).build();
 
         //when
         DmaapConsumerJsonParser dmaapConsumerJsonParser = new DmaapConsumerJsonParser();