summaryrefslogtreecommitdiffstats
path: root/prh-commons/src
diff options
context:
space:
mode:
Diffstat (limited to 'prh-commons/src')
-rw-r--r--prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java4
-rw-r--r--prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java (renamed from prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/CommonFunctions.java)9
-rw-r--r--prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java2
3 files changed, 9 insertions, 6 deletions
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java
index 6d488c85..b2bac24c 100644
--- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java
+++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java
@@ -23,6 +23,8 @@ package org.onap.dcaegen2.services.prh.model;
import com.google.gson.annotations.SerializedName;
import org.immutables.gson.Gson;
import org.immutables.value.Value;
+import org.onap.dcaegen2.services.sdk.rest.services.model.AaiModel;
+import org.onap.dcaegen2.services.sdk.rest.services.model.DmaapModel;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 5/8/18
@@ -30,7 +32,7 @@ import org.immutables.value.Value;
@Value.Immutable
@Gson.TypeAdapters(fieldNamingStrategy = true)
-public interface ConsumerDmaapModel {
+public interface ConsumerDmaapModel extends AaiModel, DmaapModel {
@SerializedName(value = "correlationId", alternate = "correlationId")
String getCorrelationId();
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/CommonFunctions.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java
index 20820fce..b504a4bd 100644
--- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/CommonFunctions.java
+++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java
@@ -22,13 +22,14 @@ package org.onap.dcaegen2.services.prh.model;
import com.google.gson.GsonBuilder;
import com.google.gson.TypeAdapterFactory;
+import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder;
+
import java.util.ServiceLoader;
-public class CommonFunctions {
+public class JsonBodyBuilderImpl implements JsonBodyBuilder<ConsumerDmaapModel> {
- private CommonFunctions() {
- }
+ public JsonBodyBuilderImpl() {}
/**
* Method for serialization object by GSON.
@@ -36,7 +37,7 @@ public class CommonFunctions {
* @param consumerDmaapModel - object which will be serialized
* @return string from serialization
*/
- public static String createJsonBody(ConsumerDmaapModel consumerDmaapModel) {
+ public String createJsonBody(ConsumerDmaapModel consumerDmaapModel) {
GsonBuilder gsonBuilder = new GsonBuilder();
ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory);
return gsonBuilder.create().toJson(ImmutableConsumerDmaapModel.builder().ipv4(consumerDmaapModel.getIpv4())
diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java
index 81a569e4..86717d7e 100644
--- a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java
+++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java
@@ -30,6 +30,6 @@ class CommonFunctionsTest {
void createJsonBody_shouldReturnJsonInString() {
String expectedResult = "{\"correlationId\":\"NOKnhfsadhff\",\"ipaddress-v4-oam\":\"256.22.33.155\""
+ ",\"ipaddress-v6-oam\":\"200J:0db8:85a3:0000:0000:8a2e:0370:7334\"}";
- assertEquals(expectedResult, CommonFunctions.createJsonBody(new ConsumerDmaapModelForUnitTest()));
+ assertEquals(expectedResult, new JsonBodyBuilderImpl().createJsonBody(new ConsumerDmaapModelForUnitTest()));
}
}