aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2018-08-30 12:02:31 +0200
committerpwielebs <piotr.wielebski@nokia.com>2018-08-30 12:02:31 +0200
commited4d45332691282e7e0dc4bb413d20f46e1a0a66 (patch)
tree5bb2c06ef453ae8868cbd0f1b04ce9375c165459
parent4fbb9e8ad097c9ec3c3434ba257e887fb3a64699 (diff)
Introduction of a new parameter "sourceName"
- used instead of pnf-name (correlationId) Change-Id: Iabcbfacbc029bd6d229080c2064a291e17c7f4f8 Issue-ID: DCAEGEN2-744 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java46
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParserTest.java130
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImplTest.java2
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java32
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java2
-rw-r--r--prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/CommonFunctions.java2
-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/ConsumerDmaapModelForUnitTest.java8
-rw-r--r--prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java2
-rw-r--r--prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelTest.java6
11 files changed, 160 insertions, 76 deletions
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java
index ff5d4bb7..0a6c9926 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java
@@ -77,7 +77,7 @@ public class AaiProducerReactiveHttpClient {
private Mono<Integer> patchAaiRequest(ConsumerDmaapModel dmaapModel) {
try {
return webClient.patch()
- .uri(getUri(dmaapModel.getPnfName()))
+ .uri(getUri(dmaapModel.getSourceName()))
.body(BodyInserters.fromObject(dmaapModel))
.retrieve()
.onStatus(
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 17b1ef67..8742d872 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
@@ -40,11 +40,11 @@ import reactor.core.publisher.Mono;
public class DmaapConsumerJsonParser {
private static final String EVENT = "event";
+ private static final String COMMON_EVENT_HEADER = "commonEventHeader";
private static final String PNF_REGISTRATION_FIELDS = "pnfRegistrationFields";
private static final String OAM_IPV_4_ADDRESS = "oamV4IpAddress";
private static final String OAM_IPV_6_ADDRESS = "oamV6IpAddress";
- private static final String VENDOR_NAME = "vendorName";
- private static final String SERIAL_NUMBER = "serialNumber";
+ private static final String SOURCE_NAME = "sourceName";
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -89,20 +89,23 @@ public class DmaapConsumerJsonParser {
: transform(monoJsonP));
}
- private Mono<ConsumerDmaapModel> transform(JsonObject monoJsonP) {
- monoJsonP = monoJsonP.getAsJsonObject(EVENT).getAsJsonObject(PNF_REGISTRATION_FIELDS);
- String pnfVendorName = getValueFromJson(monoJsonP, VENDOR_NAME);
- String pnfSerialNumber = getValueFromJson(monoJsonP, SERIAL_NUMBER);
- String pnfOamIpv4Address = getValueFromJson(monoJsonP, OAM_IPV_4_ADDRESS);
- String pnfOamIpv6Address = getValueFromJson(monoJsonP, OAM_IPV_6_ADDRESS);
- return
- (!vendorAndSerialNotEmpty(pnfSerialNumber, pnfVendorName) || !ipPropertiesNotEmpty(pnfOamIpv4Address,
- pnfOamIpv6Address))
+ private Mono<ConsumerDmaapModel> transform(JsonObject responseFromDmaap) {
+
+ JsonObject commonEventHeader = responseFromDmaap.getAsJsonObject(EVENT)
+ .getAsJsonObject(COMMON_EVENT_HEADER);
+ JsonObject pnfRegistrationFields = responseFromDmaap.getAsJsonObject(EVENT)
+ .getAsJsonObject(PNF_REGISTRATION_FIELDS);
+
+ String pnfSourceName = getValueFromJson(commonEventHeader, SOURCE_NAME);
+ String pnfOamIpv4Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_4_ADDRESS);
+ String pnfOamIpv6Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_6_ADDRESS);
+
+ return ( StringUtils.isEmpty(pnfSourceName) || !ipPropertiesNotEmpty(pnfOamIpv4Address, pnfOamIpv6Address) )
? Mono.error(new DmaapNotFoundException("Incorrect json, consumerDmaapModel can not be created: "
- + printMessage(pnfVendorName, pnfSerialNumber, pnfOamIpv4Address, pnfOamIpv6Address))) :
+ + printMessage(pnfSourceName, pnfOamIpv4Address, pnfOamIpv6Address))) :
Mono.just(ImmutableConsumerDmaapModel.builder()
- .pnfName(pnfVendorName.substring(0, Math.min(pnfVendorName.length(), 3)).toUpperCase()
- .concat(pnfSerialNumber)).ipv4(pnfOamIpv4Address)
+ .sourceName(pnfSourceName)
+ .ipv4(pnfOamIpv4Address)
.ipv6(pnfOamIpv6Address).build());
}
@@ -110,10 +113,6 @@ public class DmaapConsumerJsonParser {
return jsonObject.has(jsonKey) ? jsonObject.get(jsonKey).getAsString() : "";
}
- private boolean vendorAndSerialNotEmpty(String pnfSerialNumber, String pnfVendorName) {
- return (!StringUtils.isEmpty(pnfSerialNumber) && !StringUtils.isEmpty(pnfVendorName));
- }
-
private boolean ipPropertiesNotEmpty(String ipv4, String ipv6) {
return (!StringUtils.isEmpty(ipv4)) || !(StringUtils.isEmpty(ipv6));
}
@@ -122,12 +121,11 @@ public class DmaapConsumerJsonParser {
return jsonObject.has(EVENT) && jsonObject.getAsJsonObject(EVENT).has(PNF_REGISTRATION_FIELDS);
}
- private String printMessage(String vendorName, String serialNumber, String oamIpv4Address, String oamIpv6Address) {
+ private String printMessage(String sourceName, String oamIpv4Address, String oamIpv6Address) {
return String.format("%n{"
- + "\"" + VENDOR_NAME + " : \"%s\","
- + "\"" + SERIAL_NUMBER + "\": \"%s\","
- + "\"" + OAM_IPV_4_ADDRESS + "\": \"%s\","
- + "\"" + OAM_IPV_6_ADDRESS + "\": \"%s\""
- + "%n}", vendorName, serialNumber, oamIpv4Address, oamIpv6Address);
+ + "\"" + SOURCE_NAME + "\": \"%s\","
+ + "\"" + OAM_IPV_4_ADDRESS + "\": \"%s\","
+ + "\"" + OAM_IPV_6_ADDRESS + "\": \"%s\""
+ + "%n}", sourceName, oamIpv4Address, oamIpv6Address);
}
}
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 e0eccc36..2cbb6800 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
@@ -42,7 +42,9 @@ class DmaapConsumerJsonParserTest {
@Test
void whenPassingCorrectJson_validationNotThrowingAnException() {
//given
- String message = "[{\"event\": {\"pnfRegistrationFields\": {"
+ String message = "[{\"event\": {"
+ + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
@@ -56,7 +58,9 @@ class DmaapConsumerJsonParserTest {
+ " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\""
+ "}}}]";
- String parsed = "{\"event\": {\"pnfRegistrationFields\": {"
+ String parsed = "{\"event\": {"
+ + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
@@ -72,7 +76,7 @@ class DmaapConsumerJsonParserTest {
ConsumerDmaapModel expectedObject = ImmutableConsumerDmaapModel.builder().ipv4("10.16.123.234")
.ipv6("0:0:0:0:0:FFFF:0A10:7BEA")
- .pnfName("NOKQTFCOC540002E").build();
+ .sourceName("NOKQTFCOC540002E").build();
//when
DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
JsonElement jsonElement = new JsonParser().parse(parsed);
@@ -88,7 +92,9 @@ class DmaapConsumerJsonParserTest {
@Test
void whenPassingCorrectJsonWithoutIpv4_validationNotThrowingAnException() {
//given
- String message = "[{\"event\": {\"pnfRegistrationFields\": {"
+ String message = "[{\"event\": {"
+ + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
@@ -101,7 +107,9 @@ class DmaapConsumerJsonParserTest {
+ " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\""
+ "}}}]";
- String parsed = "{\"event\": {\"pnfRegistrationFields\": {"
+ String parsed = "{\"event\": {"
+ + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
@@ -125,7 +133,7 @@ class DmaapConsumerJsonParserTest {
//then
ConsumerDmaapModel expectedObject = ImmutableConsumerDmaapModel.builder().ipv4("")
.ipv6("0:0:0:0:0:FFFF:0A10:7BEA")
- .pnfName("NOKQTFCOC540002E").build();
+ .sourceName("NOKQTFCOC540002E").build();
Assertions.assertNotNull(consumerDmaapModel);
Assertions.assertEquals(expectedObject, consumerDmaapModel);
}
@@ -133,7 +141,9 @@ class DmaapConsumerJsonParserTest {
@Test
void whenPassingCorrectJsonWithoutIpv6_validationNotThrowingAnException() {
//given
- String message = "[{\"event\": {\"pnfRegistrationFields\": {"
+ String message = "[{\"event\": {"
+ + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
@@ -146,7 +156,9 @@ class DmaapConsumerJsonParserTest {
+ " \"softwareVersion\": \"v4.5.0.1\""
+ "}}}]";
- String parsed = "{\"event\": {\"pnfRegistrationFields\": {"
+ String parsed = "{\"event\": {"
+ + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
@@ -160,7 +172,7 @@ class DmaapConsumerJsonParserTest {
+ "}}}";
ConsumerDmaapModel expectedObject = ImmutableConsumerDmaapModel.builder().ipv4("10.16.123.234").ipv6("")
- .pnfName("NOKQTFCOC540002E").build();
+ .sourceName("NOKQTFCOC540002E").build();
//when
DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
JsonElement jsonElement = new JsonParser().parse(parsed);
@@ -175,7 +187,10 @@ class DmaapConsumerJsonParserTest {
@Test
void whenPassingCorrectJsonWithoutIpv4andIpv6_validationThrowingAnException() {
- String message = "[{\"event\": {\"pnfRegistrationFields\": {"
+ //given
+ String message = "[{\"event\": {"
+ + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
@@ -187,7 +202,9 @@ class DmaapConsumerJsonParserTest {
+ " \"softwareVersion\": \"v4.5.0.1\""
+ "}}}]";
- String parsed = "{\"event\": {\"pnfRegistrationFields\": {"
+ String parsed = "{\"event\": {"
+ + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
@@ -210,13 +227,17 @@ class DmaapConsumerJsonParserTest {
@Test
void whenPassingJsonWithoutMandatoryHeaderInformation_validationThrowingAnException() {
- String parsed = "{\"event\": {\"pnfRegistrationFields\": {"
+ String parsed = "{\"event\": {"
+ + "\"commonEventHeader\": {},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ + " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
+ " \"manufactureDate\": \"1535014037024\","
+ " \"modelNumber\": \"7BEA\",\n"
+ " \"lastServiceDate\": \"1535014037024\","
+ " \"unitFamily\": \"BBU\","
+ + " \"vendorName\": \"Nokia\","
+ " \"softwareVersion\": \"v4.5.0.1\""
+ "}}}";
@@ -224,13 +245,17 @@ class DmaapConsumerJsonParserTest {
JsonElement jsonElement = new JsonParser().parse(parsed);
Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
.when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
- String incorrectMessage = "[{\"event\": {\"pnfRegistrationFields\": {"
+ String incorrectMessage = "[{\"event\": {"
+ + "\"commonEventHeader\": {},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ + " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
+ " \"manufactureDate\": \"1535014037024\","
+ " \"modelNumber\": \"7BEA\",\n"
+ " \"lastServiceDate\": \"1535014037024\","
+ " \"unitFamily\": \"BBU\","
+ + " \"vendorName\": \"Nokia\","
+ " \"softwareVersion\": \"v4.5.0.1\""
+ "}}}]";
StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(incorrectMessage)))
@@ -238,15 +263,18 @@ class DmaapConsumerJsonParserTest {
}
@Test
- void whenPassingJsonWithoutSerialNumberOrVendorName_validationThrowingAnException() {
- String parsed = "{\"event\": {\"pnfRegistrationFields\": {"
+ void whenPassingJsonWithoutSourceName_validationThrowingAnException() {
+ String parsed = "{\"event\": {"
+ + "\"commonEventHeader\": {},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ + " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
+ " \"manufactureDate\": \"1535014037024\","
+ " \"modelNumber\": \"7BEA\",\n"
+ " \"lastServiceDate\": \"1535014037024\","
+ " \"unitFamily\": \"BBU\","
- + " \"oamV4IpAddress\": \"10.16.123.234\","
+ + " \"vendorName\": \"Nokia\","
+ " \"softwareVersion\": \"v4.5.0.1\","
+ " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\""
+ "}}}";
@@ -255,27 +283,32 @@ class DmaapConsumerJsonParserTest {
JsonElement jsonElement = new JsonParser().parse(parsed);
Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
.when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
- String jsonWithoutVendorAndSerialNumber =
- "[{\"event\": {\"pnfRegistrationFields\": {"
+ String jsonWithoutSourceName =
+ "[{\"event\": {"
+ + "\"commonEventHeader\": {},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ + " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
+ " \"manufactureDate\": \"1535014037024\","
+ " \"modelNumber\": \"7BEA\",\n"
+ " \"lastServiceDate\": \"1535014037024\","
+ " \"unitFamily\": \"BBU\","
- + " \"oamV4IpAddress\": \"10.16.123.234\","
+ + " \"vendorName\": \"Nokia\","
+ " \"softwareVersion\": \"v4.5.0.1\","
+ " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\""
+ "}}}]";
StepVerifier
- .create(dmaapConsumerJsonParser.getJsonObject(Mono.just(jsonWithoutVendorAndSerialNumber)))
+ .create(dmaapConsumerJsonParser.getJsonObject(Mono.just(jsonWithoutSourceName)))
.expectSubscription().expectError(DmaapNotFoundException.class).verify();
}
@Test
void whenPassingJsonWithoutIpInformation_validationThrowingAnException() {
String parsed =
- "{\"event\": {\"pnfRegistrationFields\": {"
+ "{\"event\": {"
+ + "\"commonEventHeader\": {\"sourceName\": \"NOKQTFCOC540002E\"},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
@@ -284,7 +317,9 @@ class DmaapConsumerJsonParserTest {
+ " \"lastServiceDate\": \"1535014037024\","
+ " \"unitFamily\": \"BBU\","
+ " \"vendorName\": \"Nokia\","
- + " \"softwareVersion\": \"v4.5.0.1\""
+ + " \"softwareVersion\": \"v4.5.0.1\","
+ + " \"oamV4IpAddress\": \"\","
+ + " \"oamV6IpAddress\": \"\""
+ "}}}";
DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
@@ -292,7 +327,9 @@ class DmaapConsumerJsonParserTest {
Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
.when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
String jsonWithoutIpInformation =
- "[{\"event\": {\"pnfRegistrationFields\": {"
+ "[{\"event\": {"
+ + "\"commonEventHeader\": {\"sourceName\": \"NOKQTFCOC540002E\"},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
@@ -301,9 +338,54 @@ class DmaapConsumerJsonParserTest {
+ " \"lastServiceDate\": \"1535014037024\","
+ " \"unitFamily\": \"BBU\","
+ " \"vendorName\": \"Nokia\","
- + " \"softwareVersion\": \"v4.5.0.1\""
+ + " \"softwareVersion\": \"v4.5.0.1\","
+ + " \"oamV4IpAddress\": \"\","
+ + " \"oamV6IpAddress\": \"\""
+ "}}}]";
StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(jsonWithoutIpInformation)))
.expectSubscription().expectError(DmaapNotFoundException.class).verify();
}
+
+ @Test
+ void whenPassingJsonWithoutSourceNameValue_validationThrowingAnException() {
+ String parsed =
+ "{\"event\": {"
+ + "\"commonEventHeader\": {\"sourceName\": \"\"},"
+ + "\"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\": \"10.16.123.234\","
+ + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\""
+ + "}}}";
+
+ DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
+ JsonElement jsonElement = new JsonParser().parse(parsed);
+ Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
+ .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
+ String jsonWithoutIpInformation =
+ "[{\"event\": {"
+ + "\"commonEventHeader\": {\"sourceName\": \"\"},"
+ + "\"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\": \"10.16.123.234\","
+ + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\""
+ + "}}}]";
+ StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(jsonWithoutIpInformation)))
+ .expectSubscription().expectError(DmaapNotFoundException.class).verify();
+ }
}
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImplTest.java
index e3d8fe2f..4589341e 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImplTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImplTest.java
@@ -76,7 +76,7 @@ class AaiProducerTaskImplTest {
.build();
consumerDmaapModel = ImmutableConsumerDmaapModel.builder().ipv4("10.16.123.234")
.ipv6("0:0:0:0:0:FFFF:0A10:7BEA")
- .pnfName("NOKQTFCOC540002E").build();
+ .sourceName("NOKQTFCOC540002E").build();
appConfig = mock(AppConfig.class);
}
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java
index d1ef97b5..6bcd9b2c 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java
@@ -67,24 +67,28 @@ class DmaapConsumerTaskImplTest {
consumerDmaapModel = ImmutableConsumerDmaapModel.builder().ipv4("10.16.123.234")
.ipv6("0:0:0:0:0:FFFF:0A10:7BEA")
- .pnfName("NOKQTFCOC540002E").build();
+ .sourceName("NOKQTFCOC540002E").build();
appConfig = mock(AppConfig.class);
- message = "[{\"event\": {\"pnfRegistrationFields\": {"
- + " \"unitType\": \"AirScale\","
- + " \"serialNumber\": \"QTFCOC540002E\","
- + " \"pnfRegistrationFieldsVersion\": \"2.0\","
- + " \"manufactureDate\": \"1535014037024\","
- + " \"modelNumber\": \"7BEA\",\n"
- + " \"lastServiceDate\": \"1535014037024\","
- + " \"unitFamily\": \"BBU\","
- + " \"vendorName\": \"Nokia\","
- + " \"oamV4IpAddress\": \"10.16.123.234\","
- + " \"softwareVersion\": \"v4.5.0.1\","
- + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\""
+ message = "[{\"event\": {"
+ + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"},"
+ + "\"pnfRegistrationFields\": {"
+ + " \"unitType\": \"AirScale\","
+ + " \"serialNumber\": \"QTFCOC540002E\","
+ + " \"pnfRegistrationFieldsVersion\": \"2.0\","
+ + " \"manufactureDate\": \"1535014037024\","
+ + " \"modelNumber\": \"7BEA\",\n"
+ + " \"lastServiceDate\": \"1535014037024\","
+ + " \"unitFamily\": \"BBU\","
+ + " \"vendorName\": \"Nokia\","
+ + " \"oamV4IpAddress\": \"10.16.123.234\","
+ + " \"softwareVersion\": \"v4.5.0.1\","
+ + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\""
+ "}}}]";
- parsed = "{\"event\": {\"pnfRegistrationFields\": {"
+ parsed = "{\"event\": {"
+ + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"},"
+ + "\"pnfRegistrationFields\": {"
+ " \"unitType\": \"AirScale\","
+ " \"serialNumber\": \"QTFCOC540002E\","
+ " \"pnfRegistrationFieldsVersion\": \"2.0\","
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java
index 662a3947..453679df 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java
@@ -64,7 +64,7 @@ class DmaapPublisherTaskImplTest {
.dmaapTopicName("unauthenticated.SEC_OTHER_OUTPUT").build();
consumerDmaapModel = ImmutableConsumerDmaapModel.builder().ipv4("10.16.123.234")
.ipv6("0:0:0:0:0:FFFF:0A10:7BEA")
- .pnfName("NOKQTFCOC540002E").build();
+ .sourceName("NOKQTFCOC540002E").build();
appConfig = mock(AppConfig.class);
}
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/CommonFunctions.java
index 66a0a998..145d9176 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/CommonFunctions.java
@@ -40,6 +40,6 @@ public class CommonFunctions {
GsonBuilder gsonBuilder = new GsonBuilder();
ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory);
return gsonBuilder.create().toJson(ImmutableConsumerDmaapModel.builder().ipv4(consumerDmaapModel.getIpv4())
- .ipv6(consumerDmaapModel.getIpv6()).pnfName(consumerDmaapModel.getPnfName()).build());
+ .ipv6(consumerDmaapModel.getIpv6()).sourceName(consumerDmaapModel.getSourceName()).build());
}
}
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 4c99ba3a..f34256c5 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
@@ -32,8 +32,8 @@ import org.immutables.value.Value;
@Gson.TypeAdapters(fieldNamingStrategy = true)
public interface ConsumerDmaapModel {
- @SerializedName(value = "pnf-name", alternate = "pnf-name")
- String getPnfName();
+ @SerializedName(value = "sourceName", alternate = "sourceName")
+ String getSourceName();
@SerializedName(value = "ipaddress-v4-oam", alternate = "ipaddress-v4-oam")
String getIpv4();
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java
index 569a7a7c..339ddb6d 100644
--- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java
+++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java
@@ -22,7 +22,7 @@ package org.onap.dcaegen2.services.prh.model;
public class ConsumerDmaapModelForUnitTest implements ConsumerDmaapModel {
- private final String pnfName;
+ private final String sourceName;
private final String ipv4;
private final String ipv6;
@@ -30,14 +30,14 @@ public class ConsumerDmaapModelForUnitTest implements ConsumerDmaapModel {
* Class for testing serialization of ConsumerDmaapModel.
*/
public ConsumerDmaapModelForUnitTest() {
- this.pnfName = "NOKnhfsadhff";
+ this.sourceName = "NOKnhfsadhff";
this.ipv4 = "256.22.33.155";
this.ipv6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
}
- public String getPnfName() {
- return pnfName;
+ public String getSourceName() {
+ return sourceName;
}
public String 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 d4c947fd..470704a2 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
@@ -47,7 +47,7 @@ class CommonFunctionsTest {
@Test
void createJsonBody_shouldReturnJsonInString() {
- String expectedResult = "{\"pnf-name\":\"NOKnhfsadhff\",\"ipaddress-v4-oam\":\"256.22.33.155\""
+ String expectedResult = "{\"sourceName\":\"NOKnhfsadhff\",\"ipaddress-v4-oam\":\"256.22.33.155\""
+ ",\"ipaddress-v6-oam\":\"2001:0db8:85a3:0000:0000:8a2e:0370:7334\"}";
assertEquals(expectedResult, CommonFunctions.createJsonBody(model));
}
diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelTest.java
index 6b2f9abc..ed8d5293 100644
--- a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelTest.java
+++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelTest.java
@@ -30,18 +30,18 @@ class ConsumerDmaapModelTest {
// When
// Given
- String pnfName = "NOKnhfsadhff";
+ String sourceName = "NOKnhfsadhff";
String ipv4 = "11.22.33.155";
String ipv6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
ConsumerDmaapModel consumerDmaapModel = ImmutableConsumerDmaapModel.builder()
- .pnfName(pnfName)
+ .sourceName(sourceName)
.ipv4(ipv4)
.ipv6(ipv6)
.build();
// Then
Assertions.assertNotNull(consumerDmaapModel);
- Assertions.assertEquals(pnfName, consumerDmaapModel.getPnfName());
+ Assertions.assertEquals(sourceName, consumerDmaapModel.getSourceName());
Assertions.assertEquals(ipv4, consumerDmaapModel.getIpv4());
Assertions.assertEquals(ipv6, consumerDmaapModel.getIpv6());
}