aboutsummaryrefslogtreecommitdiffstats
path: root/prh-app-server
diff options
context:
space:
mode:
Diffstat (limited to 'prh-app-server')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java36
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParserTest.java318
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java52
3 files changed, 232 insertions, 174 deletions
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 1b8aaca3..d7bbfd2c 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
@@ -37,12 +37,11 @@ import reactor.core.publisher.Mono;
*/
public class DmaapConsumerJsonParser {
- private static final String EVENT = "event";
- private static final String OTHER_FIELDS = "otherFields";
- private static final String PNF_OAM_IPV_4_ADDRESS = "pnfOamIpv4Address";
- private static final String PNF_OAM_IPV_6_ADDRESS = "pnfOamIpv6Address";
- private static final String PNF_VENDOR_NAME = "pnfVendorName";
- private static final String PNF_SERIAL_NUMBER = "pnfSerialNumber";
+ 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";
/**
* Extract info from string and create @see {@link org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel}.
@@ -85,11 +84,11 @@ public class DmaapConsumerJsonParser {
}
private Mono<ConsumerDmaapModel> transform(JsonObject monoJsonP) {
- monoJsonP = monoJsonP.getAsJsonObject(EVENT).getAsJsonObject(OTHER_FIELDS);
- String pnfVendorName = getValueFromJson(monoJsonP, PNF_VENDOR_NAME);
- String pnfSerialNumber = getValueFromJson(monoJsonP, PNF_SERIAL_NUMBER);
- String pnfOamIpv4Address = getValueFromJson(monoJsonP, PNF_OAM_IPV_4_ADDRESS);
- String pnfOamIpv6Address = getValueFromJson(monoJsonP, PNF_OAM_IPV_6_ADDRESS);
+ monoJsonP = monoJsonP.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))
@@ -114,16 +113,15 @@ public class DmaapConsumerJsonParser {
}
private boolean containsHeader(JsonObject jsonObject) {
- return jsonObject.has(EVENT) && jsonObject.getAsJsonObject(EVENT).has(OTHER_FIELDS);
+ return jsonObject.has(PNF_REGISTRATION_FIELDS);
}
- private String printMessage(String pnfVendorName, String pnfSerialNumber, String pnfOamIpv4Address,
- String pnfOamIpv6Address) {
+ private String printMessage(String vendorName, String serialNumber, String oamIpv4Address, String oamIpv6Address) {
return String.format("%n{"
- + "\"pnfVendorName\" : \"%s\","
- + "\"pnfSerialNumber\": \"%s\","
- + "\"pnfOamIpv4Address\": \"%s\","
- + "\"pnfOamIpv6Address\": \"%s\""
- + "%n}", pnfVendorName, pnfSerialNumber, pnfOamIpv4Address, pnfOamIpv6Address);
+ + "\"" + VENDOR_NAME + " : \"%s\","
+ + "\"" + SERIAL_NUMBER + "\": \"%s\","
+ + "\"" + OAM_IPV_4_ADDRESS + "\": \"%s\","
+ + "\"" + OAM_IPV_6_ADDRESS + "\": \"%s\""
+ + "%n}", vendorName, serialNumber, 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 cc2a593f..8cf7bcec 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,29 +42,37 @@ class DmaapConsumerJsonParserTest {
@Test
void whenPassingCorrectJson_validationNotThrowingAnException() {
//given
- String message =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\""
- + ":{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\":"
- + "3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\":1517206400"
- + ",\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv4Address\":"
- + "\"10.16.123.234\",\"pnfOamIpv6Address\":\"0:0:0:0:0:FFFF:0A10:7BEA\",\"pnfSerialNumber\":"
- + "\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":"
- + "\"Nokia\"}}}]";
- String parsed =
- "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\",\"eventName\""
- + ":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":{},"
- + "\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\":"
- + "3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\":"
- + "1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv4Address\":"
- + "\"10.16.123.234\",\"pnfOamIpv6Address\":\"0:0:0:0:0:FFFF:0A10:7BEA\",\"pnfSerialNumber\":"
- + "\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":"
- + "\"Nokia\"}}}";
+ String message = "[{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"oamV4IpAddress\":\"10.16.123.234\","
+ + "\"oamV6IpAddress\":\"0:0:0:0:0:FFFF:0A10:7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"v4.5.0.1\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\","
+ + "\"vendorName\":\"Nokia\""
+ + "}}]";
+
+ String parsed = "{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"oamV4IpAddress\":\"10.16.123.234\","
+ + "\"oamV6IpAddress\":\"0:0:0:0:0:FFFF:0A10:7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"v4.5.0.1\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\","
+ + "\"vendorName\":\"Nokia\""
+ + "}}";
+
ConsumerDmaapModel expectedObject = ImmutableConsumerDmaapModel.builder().ipv4("10.16.123.234")
.ipv6("0:0:0:0:0:FFFF:0A10:7BEA")
.pnfName("NOKQTFCOC540002E").build();
@@ -83,27 +91,31 @@ class DmaapConsumerJsonParserTest {
@Test
void whenPassingCorrectJsonWithoutIpv4_validationNotThrowingAnException() {
//given
- String message =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":"
- + "{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\":3}"
- + ",\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\":1517206400,"
- + "\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv6Address\":"
- + "\"0:0:0:0:0:FFFF:0A10:7BEA\",\"pnfSerialNumber\":\"QTFCOC540002E\",\"pnfSoftwareVersion\""
- + ":\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":\"Nokia\"}}}]";
+ String message = "[{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\",\"modelNumber\":\"7BEA\","
+ + "\"oamV6IpAddress\":\"0:0:0:0:0:FFFF:0A10:7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"1517206400\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\",\"vendorName\":\"Nokia\""
+ + "}}]";
- String parsed =
- "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\",\"eventName\""
- + ":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":{},"
- + "\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\":3}"
- + ",\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\":1517206400,"
- + "\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv6Address\":"
- + "\"0:0:0:0:0:FFFF:0A10:7BEA\",\"pnfSerialNumber\":\"QTFCOC540002E\",\"pnfSoftwareVersion\""
- + ":\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":\"Nokia\"}}}";
+ String parsed = "{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"oamV6IpAddress\":\"0:0:0:0:0:FFFF:0A10:7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"1517206400\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\","
+ + "\"vendorName\":\"Nokia\""
+ + "}}";
//when
DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
@@ -122,28 +134,35 @@ class DmaapConsumerJsonParserTest {
}
@Test
- void whenPassingCorrectJsonWihoutIpv6_validationNotThrowingAnException() {
+ void whenPassingCorrectJsonWithoutIpv6_validationNotThrowingAnException() {
//given
- String message =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":"
- + "{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,"
- + "\"version\":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate"
- + "\":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv4Address"
- + "\":\"10.16.123.234\",\"pnfSerialNumber\":\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\","
- + "\"pnfType\":\"AirScale\",\"pnfVendorName\":\"Nokia\"}}}]";
- String parsed =
- "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\",\"eventName\""
- + ":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":{},"
- + "\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,"
- + "\"version\":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate"
- + "\":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv4Address"
- + "\":\"10.16.123.234\",\"pnfSerialNumber\":\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\","
- + "\"pnfType\":\"AirScale\",\"pnfVendorName\":\"Nokia\"}}}";
+ String message = "[{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"oamV4IpAddress\":\"10.16.123.234\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"1517206400\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\","
+ + "\"vendorName\":\"Nokia\""
+ + "}}]";
+
+ String parsed = "{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"oamV4IpAddress\":\"10.16.123.234\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"1517206400\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\","
+ + "\"vendorName\":\"Nokia\""
+ + "}}";
ConsumerDmaapModel expectedObject = ImmutableConsumerDmaapModel.builder().ipv4("10.16.123.234").ipv6("")
.pnfName("NOKQTFCOC540002E").build();
@@ -160,25 +179,33 @@ class DmaapConsumerJsonParserTest {
}
@Test
- void whenPassingCorrectJsonWihoutIpv4andIpv6_validationThrowingAnException() {
- String message =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":"
- + "{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\""
- + ":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\""
- + ":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfSoftwareVersion\":"
- + "\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":\"Nokia\"}}}]";
- String parsed =
- "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\",\"eventName\""
- + ":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":{},"
- + "\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\""
- + ":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\""
- + ":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfSoftwareVersion\":"
- + "\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":\"Nokia\"}}}";
+ void whenPassingCorrectJsonWithoutIpv4andIpv6_validationThrowingAnException() {
+ String message = "[{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"1517206400\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\","
+ + "\"vendorName\":\"Nokia\""
+ + "}}]";
+
+ String parsed = "{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"1517206400\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\","
+ + "\"vendorName\":\"Nokia\""
+ + "}}";
+
DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
JsonElement jsonElement = new JsonParser().parse(parsed);
Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
@@ -190,82 +217,107 @@ class DmaapConsumerJsonParserTest {
@Test
void whenPassingJsonWithoutMandatoryHeaderInformation_validationThrowingAnException() {
- String parsed = "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\""
- + ",\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":{},"
- + "\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\",\"priority\""
- + ":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":\"<<SerialNumber>>\","
- + "\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\":3}}}";
+ String parsed = "{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"1517206400\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\""
+ + "}}";
+
DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
JsonElement jsonElement = new JsonParser().parse(parsed);
Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
.when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
- String incorrectMessage =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\""
- + ",\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":"
- + "{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\":3"
- + "}}}]";
+ String incorrectMessage = "[{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"1517206400\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\""
+ + "}}]";
StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(incorrectMessage)))
.expectSubscription().expectError(DmaapNotFoundException.class).verify();
}
@Test
- void whenPassingJsonWithoutPnfSerialNumberOrPnfVendorName_validationThrowingAnException() {
- String parsed = "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":"
- + "\"<<SerialNumber>>-reg\",\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\""
- + "internalHeaderFields\":{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\","
- + "\"nfcNamingCode\":\"5DU\",\"priority\":\"Normal\",reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,"
- + "\"sourceId\":\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",startEpochMicrosec\":1519837825682,\""
- + "version\":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\""
- + ":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv4Address\":"
- + "\"10.16.123.234\",\"pnfOamIpv6Address\":\"0:0:0:0:0:FFFF:0A10:7BEA\",\"pnfSoftwareVersion\":"
- + "\"v4.5.0.1\",\"pnfType\":\"AirScale\"}}}";
+ void whenPassingJsonWithoutSerialNumberOrVendorName_validationThrowingAnException() {
+ String parsed = "{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"oamV4IpAddress\":\"10.16.123.234\","
+ + "\"oamV6IpAddress\":\"0:0:0:0:0:FFFF:0A10:7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"softwareVersion\":\"v4.5.0.1\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\""
+ + "}}";
+
DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
JsonElement jsonElement = new JsonParser().parse(parsed);
Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
.when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
- String jsonWithoutPnfVendorAndSerialNumber =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":"
- + "\"<<SerialNumber>>-reg\",\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\""
- + "internalHeaderFields\":{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\","
- + "\"nfcNamingCode\":\"5DU\",\"priority\":\"Normal\",reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,"
- + "\"sourceId\":\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",startEpochMicrosec\":1519837825682,"
- + "\"version\":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\","
- + "\"pnfLastServiceDate\":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\","
- + "\"pnfOamIpv4Address\":\"10.16.123.234\",\"pnfOamIpv6Address\":\"0:0:0:0:0:FFFF:0A10:7BEA\","
- + "\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":\"AirScale\"}}}]";
+ String jsonWithoutVendorAndSerialNumber =
+ "[{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"oamV4IpAddress\":\"10.16.123.234\","
+ + "\"oamV6IpAddress\":\"0:0:0:0:0:FFFF:0A10:7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"softwareVersion\":\"v4.5.0.1\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\""
+ + "}}]";
StepVerifier
- .create(dmaapConsumerJsonParser.getJsonObject(Mono.just(jsonWithoutPnfVendorAndSerialNumber)))
+ .create(dmaapConsumerJsonParser.getJsonObject(Mono.just(jsonWithoutVendorAndSerialNumber)))
.expectSubscription().expectError(DmaapNotFoundException.class).verify();
}
@Test
void whenPassingJsonWithoutIpInformation_validationThrowingAnException() {
String parsed =
- "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\""
- + ":{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\""
- + ":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\":"
- + "1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":"
- + "\"AJ02\",\"pnfSerialNumber\":\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":"
- + "\"AirScale\"," + "\"pnfVendorName\":\"Nokia\"}}}";
+ "{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"v4.5.0.1\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\","
+ + "\"vendorName\":\"Nokia\""
+ + "}}";
+
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\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\""
- + ":{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\""
- + ":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\""
- + ":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfSerialNumber\""
- + ":\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":\"AirScale\","
- + "\"pnfVendorName\":\"Nokia\"}}}]";
+ "[{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"v4.5.0.1\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\","
+ + "\"vendorName\":\"Nokia\""
+ + "}}]";
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/DmaapConsumerTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java
index 6baa7463..c8676c7c 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
@@ -69,28 +69,36 @@ class DmaapConsumerTaskImplTest {
.ipv6("0:0:0:0:0:FFFF:0A10:7BEA")
.pnfName("NOKQTFCOC540002E").build();
appConfig = mock(AppConfig.class);
- message =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\""
- + ":{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\""
- + ":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\":"
- + "1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv4Address\":"
- + "\"10.16.123.234\",\"pnfOamIpv6Address\":\"0:0:0:0:0:FFFF:0A10:7BEA\",\"pnfSerialNumber\":"
- + "\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":"
- + "\"Nokia\"}}}]";
- parsed =
- "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\",\"eventName\""
- + ":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":{},"
- + "\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,"
- + "\"version\":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\","
- + "\"pnfLastServiceDate\":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\","
- + "\"pnfOamIpv4Address\":\"10.16.123.234\",\"pnfOamIpv6Address\":\"0:0:0:0:0:FFFF:0A10:7BEA\","
- + "\"pnfSerialNumber\":\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":\"AirScale\","
- + "\"pnfVendorName\":\"Nokia\"}}}";
+
+ message = "[{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"oamV4IpAddress\":\"10.16.123.234\","
+ + "\"oamV6IpAddress\":\"0:0:0:0:0:FFFF:0A10:7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"v4.5.0.1\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\","
+ + "\"vendorName\":\"Nokia\""
+ + "}}]";
+
+ parsed = "{\"pnfRegistrationFields\":{"
+ + "\"lastServiceDate\":\"1517206400\","
+ + "\"macAddress\":\"FFFF:0A10:7BEA\","
+ + "\"manufactureDate\":\"1517206400\","
+ + "\"modelNumber\":\"7BEA\","
+ + "\"oamV4IpAddress\":\"10.16.123.234\","
+ + "\"oamV6IpAddress\":\"0:0:0:0:0:FFFF:0A10:7BEA\","
+ + "\"pnfRegistrationFieldsVersion\":\"1517206400\","
+ + "\"serialNumber\":\"QTFCOC540002E\","
+ + "\"softwareVersion\":\"v4.5.0.1\","
+ + "\"unitFamily\":\"BBU\","
+ + "\"unitType\":\"AirScale\","
+ + "\"vendorName\":\"Nokia\""
+ + "}}";
}
@Test