summaryrefslogtreecommitdiffstats
path: root/prh-commons
diff options
context:
space:
mode:
authorJoanna Jeremicz <joanna.jeremicz@nokia.com>2019-03-14 08:52:17 +0100
committerJoanna Jeremicz <joanna.jeremicz@nokia.com>2019-03-14 09:37:07 +0100
commitda01e853388b3715a4da488a73a10522e90bf0ed (patch)
tree9f25184027034f47c9f3a72b266e600fe7ad7aaa /prh-commons
parentc69d68d5669e45c969fd1293aa76c78d55a95dca (diff)
Revert IP information removal
Change-Id: I43cdc2f2086f884df1f74dfbf999addae2019b5e Issue-ID: DCAEGEN2-1312 Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
Diffstat (limited to 'prh-commons')
-rw-r--r--prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java6
-rw-r--r--prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java8
-rw-r--r--prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java4
3 files changed, 16 insertions, 2 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 d8eefec1..f6b817ef 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
@@ -38,6 +38,12 @@ public interface ConsumerDmaapModel extends AaiModel, DmaapModel {
@SerializedName(value = "correlationId", alternate = "correlationId")
String getCorrelationId();
+ @SerializedName(value = "ipaddress-v4-oam", alternate = "ipaddress-v4-oam")
+ String getIpv4();
+
+ @SerializedName(value = "ipaddress-v6-oam", alternate = "ipaddress-v6-oam")
+ String getIpv6();
+
@SerializedName(value = "serial-number", alternate = "serial-number")
String getSerialNumber();
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java
index f04168c2..d031b1b5 100644
--- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java
+++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java
@@ -42,7 +42,9 @@ public class JsonBodyBuilderImpl implements JsonBodyBuilder<ConsumerDmaapModel>
public String createJsonBody(ConsumerDmaapModel consumerDmaapModel) {
GsonBuilder gsonBuilder = new GsonBuilder();
ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory);
- return filterOutAdditionalFieldsIfEmpty(gsonBuilder.create().toJson(ImmutableConsumerDmaapModel.builder()
+ return filterOutRedundantFields(gsonBuilder.create().toJson(ImmutableConsumerDmaapModel.builder()
+ .ipv4(consumerDmaapModel.getIpv4())
+ .ipv6(consumerDmaapModel.getIpv6())
.correlationId(consumerDmaapModel.getCorrelationId())
.serialNumber(consumerDmaapModel.getSerialNumber())
.equipVendor(consumerDmaapModel.getEquipVendor())
@@ -54,11 +56,13 @@ public class JsonBodyBuilderImpl implements JsonBodyBuilder<ConsumerDmaapModel>
.build()));
}
- private String filterOutAdditionalFieldsIfEmpty(String json) {
+ private String filterOutRedundantFields(String json) {
JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();
if(jsonObject.get(ADDITIONAL_FIELDS).equals(new JsonObject())) {
jsonObject.remove(ADDITIONAL_FIELDS);
}
+ jsonObject.remove("ipaddress-v4-oam");
+ jsonObject.remove("ipaddress-v6-oam");
return jsonObject.toString();
}
} \ No newline at end of file
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 6b2ddf56..8622a169 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
@@ -39,6 +39,8 @@ class CommonFunctionsTest {
ConsumerDmaapModel model = ImmutableConsumerDmaapModel.builder()
.correlationId("NOKnhfsadhff")
+ .ipv4("256.22.33.155")
+ .ipv6("200J:0db8:85a3:0000:0000:8a2e:0370:7334")
.serialNumber("1234")
.equipVendor("NOKIA")
.equipModel("3310")
@@ -66,6 +68,8 @@ class CommonFunctionsTest {
void createJsonBodyWithEmptyOptionalPnfRegistrationFields_shouldReturnJsonInString() {
ConsumerDmaapModel model = ImmutableConsumerDmaapModel.builder()
.correlationId("NOKnhfsadhff")
+ .ipv4("256.22.33.155")
+ .ipv6("200J:0db8:85a3:0000:0000:8a2e:0370:7334")
.serialNumber("")
.equipVendor("")
.equipModel("")