diff options
Diffstat (limited to 'datafile-commons')
4 files changed, 10 insertions, 6 deletions
diff --git a/datafile-commons/pom.xml b/datafile-commons/pom.xml index 4ef2c686..400ca28a 100644 --- a/datafile-commons/pom.xml +++ b/datafile-commons/pom.xml @@ -33,6 +33,10 @@ <dependencies> <dependency> + <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId> + <artifactId>common-dependency</artifactId> + </dependency> + <dependency> <groupId>org.immutables</groupId> <artifactId>value</artifactId> </dependency> diff --git a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctions.java b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctions.java index 3be7bcf6..801f1705 100644 --- a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctions.java +++ b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctions.java @@ -20,15 +20,14 @@ package org.onap.dcaegen2.collectors.datafile.model; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder; -public class CommonFunctions { +public class CommonFunctions implements JsonBodyBuilder<ConsumerDmaapModel> { private static Gson gson = new GsonBuilder().serializeNulls().create(); - private CommonFunctions() {} - - public static String createJsonBody(ConsumerDmaapModel consumerDmaapModel) { + public String createJsonBody(ConsumerDmaapModel consumerDmaapModel) { return gson.toJson(consumerDmaapModel); } } diff --git a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModel.java b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModel.java index 62315602..883a73af 100644 --- a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModel.java +++ b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModel.java @@ -20,6 +20,7 @@ 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.DmaapModel; /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 5/8/18 @@ -28,7 +29,7 @@ import org.immutables.value.Value; @Value.Immutable @Gson.TypeAdapters -public interface ConsumerDmaapModel { +public interface ConsumerDmaapModel extends DmaapModel { @SerializedName("productName") String getProductName(); diff --git a/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctionsTest.java b/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctionsTest.java index 572bca85..cb6c48d9 100644 --- a/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctionsTest.java +++ b/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctionsTest.java @@ -53,6 +53,6 @@ class CommonFunctionsTest { // @formatter:on @Test void createJsonBody_shouldReturnJsonInString() { - assertEquals(EXPECTED_RESULT, CommonFunctions.createJsonBody(model)); + assertEquals(EXPECTED_RESULT, new CommonFunctions().createJsonBody(model)); } } |