diff options
5 files changed, 130 insertions, 103 deletions
@@ -50,7 +50,7 @@ <spring-boot.version>2.1.2.RELEASE</spring-boot.version> <springfox.version>2.9.2</springfox.version> <immutables.version>2.7.5</immutables.version> - <sdk.version>1.1.0-SNAPSHOT</sdk.version> + <sdk.version>1.1.2-SNAPSHOT</sdk.version> </properties> <modules> 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 f47231df..7532c5d8 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 @@ -119,13 +119,14 @@ public class DmaapConsumerJsonParser { .getAsJsonObject(PNF_REGISTRATION_FIELDS); this.pnfSourceName = getValueFromJson(commonEventHeader, SOURCE_NAME); + this.pnfNfRoleAdditionalField = getValueFromJson(commonEventHeader, NF_ROLE); + this.pnfOamIpv4Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_4_ADDRESS); this.pnfOamIpv6Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_6_ADDRESS); this.pnfSerialNumberAdditionalField = getValueFromJson(pnfRegistrationFields, SERIAL_NUMBER); this.pnfEquipVendorAdditionalField = getValueFromJson(pnfRegistrationFields, EQUIP_VENDOR); this.pnfEquipModelAdditionalField = getValueFromJson(pnfRegistrationFields, EQUIP_MODEL); this.pnfEquipTypeAdditionalField = getValueFromJson(pnfRegistrationFields, EQUIP_TYPE); - this.pnfNfRoleAdditionalField = getValueFromJson(pnfRegistrationFields, NF_ROLE); this.pnfSwVersionAdditionalField = getValueFromJson(pnfRegistrationFields, SW_VERSION); return (StringUtils.isEmpty(pnfSourceName) || !ipPropertiesNotEmpty(pnfOamIpv4Address, pnfOamIpv6Address)) diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PnfRegistrationFields.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PnfRegistrationFields.java index c2c2b741..a9a28c0c 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PnfRegistrationFields.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PnfRegistrationFields.java @@ -33,12 +33,12 @@ class PnfRegistrationFields { static final String CORRELATION_ID = "correlationId"; // additional fields - static final String SERIAL_NUMBER = "serial-number"; - static final String EQUIP_VENDOR = "equip-vendor"; - static final String EQUIP_MODEL = "equip-model"; - static final String EQUIP_TYPE = "equip-type"; - static final String NF_ROLE = "nf-role"; - static final String SW_VERSION = "sw-version"; + static final String SERIAL_NUMBER = "serialNumber"; + static final String EQUIP_VENDOR = "vendorName"; + static final String EQUIP_MODEL = "modelNumber"; + static final String EQUIP_TYPE = "unitType"; + static final String NF_ROLE = "nfNamingCode"; + static final String SW_VERSION = "softwareVersion"; private PnfRegistrationFields() {} } 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 591276b0..44651a54 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,31 +42,36 @@ class DmaapConsumerJsonParserTest { void whenPassingCorrectJson_validationNotThrowingAnException() { //given String message = "[{\"event\": {" - + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"}," + + "\"commonEventHeader\": { " + + " \"sourceName\":\"NOKQTFCOC540002E\"," + + " \"nfNamingCode\":\"gNB\" " + + "}," + "\"pnfRegistrationFields\": {" - + " \"equip-vendor\": \"nokia\"," - + " \"serial-number\": \"QTFCOC540002E\"," + + " \"vendorName\": \"nokia\"," + + " \"serialNumber\": \"QTFCOC540002E\"," + " \"pnfRegistrationFieldsVersion\": \"2.0\"," - + " \"equip-model\": \"3310\"," - + " \"equip-type\": \"type\",\n" - + " \"nf-role\": \"role\"," + + " \"modelNumber\": \"3310\"," + + " \"unitType\": \"type\",\n" + + " \"unitFamily\": \"BBU\"," + " \"oamV4IpAddress\": \"10.16.123.234\"," - + " \"sw-version\": \"v4.5.0.1\"," + + " \"softwareVersion\": \"v4.5.0.1\"," + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\"" + "}}}]"; String parsed = "{\"event\": {" - + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"}," + + "\"commonEventHeader\": { " + + " \"sourceName\":\"NOKQTFCOC540002E\"," + + " \"nfNamingCode\":\"gNB\" " + + "}," + "\"pnfRegistrationFields\": {" - + " \"equip-vendor\": \"nokia\"," - + " \"serial-number\": \"QTFCOC540002E\"," + + " \"vendorName\": \"nokia\"," + + " \"serialNumber\": \"QTFCOC540002E\"," + " \"pnfRegistrationFieldsVersion\": \"2.0\"," - + " \"equip-model\": \"3310\"," - + " \"equip-type\": \"type\",\n" - + " \"nf-role\": \"role\"," + + " \"modelNumber\": \"3310\"," + + " \"unitType\": \"type\",\n" + " \"unitFamily\": \"BBU\"," + " \"oamV4IpAddress\": \"10.16.123.234\"," - + " \"sw-version\": \"v4.5.0.1\"," + + " \"softwareVersion\": \"v4.5.0.1\"," + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\"" + "}}}"; @@ -78,7 +83,7 @@ class DmaapConsumerJsonParserTest { .equipVendor("nokia") .equipModel("3310") .equipType("type") - .nfRole("role") + .nfRole("gNB") .swVersion("v4.5.0.1") .build(); //when @@ -97,30 +102,34 @@ class DmaapConsumerJsonParserTest { void whenPassingCorrectJsonWithoutIpv4_validationNotThrowingAnException() { //given String message = "[{\"event\": {" - + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"}," + + "\"commonEventHeader\": { " + + " \"sourceName\":\"NOKQTFCOC540002E\"," + + " \"nfNamingCode\":\"gNB\" " + + "}," + "\"pnfRegistrationFields\": {" - + " \"equip-vendor\": \"nokia\"," - + " \"serial-number\": \"QTFCOC540002E\"," + + " \"vendorName\": \"nokia\"," + + " \"serialNumber\": \"QTFCOC540002E\"," + " \"pnfRegistrationFieldsVersion\": \"2.0\"," - + " \"equip-model\": \"3310\"," - + " \"equip-type\": \"type\",\n" - + " \"nf-role\": \"role\"," + + " \"modelNumber\": \"3310\"," + + " \"unitType\": \"type\",\n" + " \"unitFamily\": \"BBU\"," - + " \"sw-version\": \"v4.5.0.1\"," + + " \"softwareVersion\": \"v4.5.0.1\"," + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\"" + "}}}]"; String parsed = "{\"event\": {" - + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"}," + + "\"commonEventHeader\": { " + + " \"sourceName\":\"NOKQTFCOC540002E\"," + + " \"nfNamingCode\":\"gNB\" " + + "}," + "\"pnfRegistrationFields\": {" - + " \"equip-vendor\": \"nokia\"," - + " \"serial-number\": \"QTFCOC540002E\"," + + " \"vendorName\": \"nokia\"," + + " \"serialNumber\": \"QTFCOC540002E\"," + " \"pnfRegistrationFieldsVersion\": \"2.0\"," - + " \"equip-model\": \"3310\"," - + " \"equip-type\": \"type\",\n" - + " \"nf-role\": \"role\"," + + " \"modelNumber\": \"3310\"," + + " \"unitType\": \"type\",\n" + " \"unitFamily\": \"BBU\"," - + " \"sw-version\": \"v4.5.0.1\"," + + " \"softwareVersion\": \"v4.5.0.1\"," + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\"" + "}}}"; @@ -141,7 +150,7 @@ class DmaapConsumerJsonParserTest { .equipVendor("nokia") .equipModel("3310") .equipType("type") - .nfRole("role") + .nfRole("gNB") .swVersion("v4.5.0.1") .build(); Assertions.assertNotNull(consumerDmaapModel); @@ -152,33 +161,39 @@ class DmaapConsumerJsonParserTest { void whenPassingCorrectJsonWithoutIpv6_validationNotThrowingAnException() { //given String message = "[{\"event\": {" - + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"}," + + "\"commonEventHeader\": { " + + " \"sourceName\":\"NOKQTFCOC540002E\"," + + " \"nfNamingCode\":\"gNB\" " + + "}," + "\"pnfRegistrationFields\": {" - + " \"equip-vendor\": \"nokia\"," - + " \"serial-number\": \"QTFCOC540002E\"," + + " \"vendorName\": \"nokia\"," + + " \"serialNumber\": \"QTFCOC540002E\"," + " \"pnfRegistrationFieldsVersion\": \"2.0\"," - + " \"equip-model\": \"3310\"," - + " \"equip-type\": \"type\",\n" - + " \"nf-role\": \"role\"," + + " \"modelNumber\": \"3310\"," + + " \"unitType\": \"type\",\n" + " \"unitFamily\": \"BBU\"," + " \"oamV4IpAddress\": \"10.16.123.234\"," - + " \"sw-version\": \"v4.5.0.1\"" + + " \"softwareVersion\": \"v4.5.0.1\"" + "}}}]"; + String parsed = "{\"event\": {" - + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"}," + + "\"commonEventHeader\": { " + + " \"sourceName\":\"NOKQTFCOC540002E\"," + + " \"nfNamingCode\":\"gNB\" " + + "}," + "\"pnfRegistrationFields\": {" - + " \"equip-vendor\": \"nokia\"," - + " \"serial-number\": \"QTFCOC540002E\"," + + " \"vendorName\": \"nokia\"," + + " \"serialNumber\": \"QTFCOC540002E\"," + " \"pnfRegistrationFieldsVersion\": \"2.0\"," - + " \"equip-model\": \"3310\"," - + " \"equip-type\": \"type\",\n" - + " \"nf-role\": \"role\"," + + " \"modelNumber\": \"3310\"," + + " \"unitType\": \"type\",\n" + " \"unitFamily\": \"BBU\"," + " \"oamV4IpAddress\": \"10.16.123.234\"," - + " \"sw-version\": \"v4.5.0.1\"" + + " \"softwareVersion\": \"v4.5.0.1\"" + "}}}"; + ConsumerDmaapModel expectedObject = ImmutableConsumerDmaapModel.builder() .ipv4("10.16.123.234") .ipv6("") @@ -187,7 +202,7 @@ class DmaapConsumerJsonParserTest { .equipVendor("nokia") .equipModel("3310") .equipType("type") - .nfRole("role") + .nfRole("gNB") .swVersion("v4.5.0.1") .build(); //when @@ -206,32 +221,34 @@ class DmaapConsumerJsonParserTest { void whenPassingCorrectJsonWithoutIpv4andIpv6_validationAddingAnException() { //given String message = "[{\"event\": {" - + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"}," - + "\"pnfRegistrationFields\": {" - + " \"unitType\": \"AirScale\"," - + " \"serialNumber\": \"QTFCOC540002E\"," - + " \"pnfRegistrationFieldsVersion\": \"2.0\"," - + " \"manufactureDate\": \"1535014037024\"," - + " \"modelNumber\": \"7BEA\",\n" - + " \"lastServiceDate\": \"1535014037024\"," - + " \"unitFamily\": \"BBU\"," - + " \"vendorName\": \"Nokia\"," - + " \"softwareVersion\": \"v4.5.0.1\"" - + "}}}]"; + + "\"commonEventHeader\": { " + + " \"sourceName\":\"NOKQTFCOC540002E\"," + + " \"nfNamingCode\":\"gNB\" " + + "}," + + "\"pnfRegistrationFields\": {" + + " \"vendorName\": \"nokia\"," + + " \"serialNumber\": \"QTFCOC540002E\"," + + " \"pnfRegistrationFieldsVersion\": \"2.0\"," + + " \"modelNumber\": \"3310\"," + + " \"unitType\": \"type\",\n" + + " \"unitFamily\": \"BBU\"," + + " \"softwareVersion\": \"v4.5.0.1\"" + + "}}}]"; String parsed = "{\"event\": {" - + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"}," - + "\"pnfRegistrationFields\": {" - + " \"unitType\": \"AirScale\"," - + " \"serialNumber\": \"QTFCOC540002E\"," - + " \"pnfRegistrationFieldsVersion\": \"2.0\"," - + " \"manufactureDate\": \"1535014037024\"," - + " \"modelNumber\": \"7BEA\",\n" - + " \"lastServiceDate\": \"1535014037024\"," - + " \"unitFamily\": \"BBU\"," - + " \"vendorName\": \"Nokia\"," - + " \"softwareVersion\": \"v4.5.0.1\"" - + "}}}"; + + "\"commonEventHeader\": { " + + " \"sourceName\":\"NOKQTFCOC540002E\"," + + " \"nfNamingCode\":\"gNB\" " + + "}," + + "\"pnfRegistrationFields\": {" + + " \"vendorName\": \"nokia\"," + + " \"serialNumber\": \"QTFCOC540002E\"," + + " \"pnfRegistrationFieldsVersion\": \"2.0\"," + + " \"modelNumber\": \"3310\"," + + " \"unitType\": \"type\",\n" + + " \"unitFamily\": \"BBU\"," + + " \"softwareVersion\": \"v4.5.0.1\"" + + "}}}"; DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser()); JsonElement jsonElement = new JsonParser().parse(parsed); @@ -410,34 +427,41 @@ class DmaapConsumerJsonParserTest { @Test void whenPassingCorrectJsoArrayWithoutIpv4_validationNotThrowingAnException() { //given - String message = - "[{\"event\": {" - + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"}," + String message = "[{\"event\": {" + + "\"commonEventHeader\": { " + + " \"sourceName\":\"NOKQTFCOC540002E\"," + + " \"nfNamingCode\":\"gNB\" " + + " }," + "\"pnfRegistrationFields\": {" - + " \"equip-vendor\": \"nokia\"," - + " \"serial-number\": \"QTFCOC540002E\"," + + " \"vendorName\": \"nokia\"," + + " \"serialNumber\": \"QTFCOC540002E\"," + " \"pnfRegistrationFieldsVersion\": \"2.0\"," - + " \"equip-model\": \"3310\"," - + " \"equip-type\": \"type\",\n" - + " \"nf-role\": \"role\"," + + " \"modelNumber\": \"3310\"," + + " \"unitType\": \"type\",\n" + " \"unitFamily\": \"BBU\"," - + " \"sw-version\": \"v4.5.0.1\"," + + " \"softwareVersion\": \"v4.5.0.1\"," + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\"" + "}}}," - + "{\"event\": {" - + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"}," + + " {\"event\": {" + + "\"commonEventHeader\": { " + + " \"sourceName\":\"NOKQTFCOC540002E\"," + + " \"nfNamingCode\":\"gNB\" " + + "}," + "\"pnfRegistrationFields\": {" - + " \"equip-vendor\": \"nokia\"," - + " \"serial-number\": \"QTFCOC540002E\"," + + " \"vendorName\": \"nokia\"," + + " \"serialNumber\": \"QTFCOC540002E\"," + " \"pnfRegistrationFieldsVersion\": \"2.0\"," - + " \"equip-model\": \"3310\"," - + " \"equip-type\": \"type\",\n" - + " \"nf-role\": \"role\"," + + " \"modelNumber\": \"3310\"," + + " \"unitType\": \"type\",\n" + " \"unitFamily\": \"BBU\"," - + " \"sw-version\": \"v4.5.0.1\"," + + " \"softwareVersion\": \"v4.5.0.1\"," + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\"" + "}}}]"; + + + + ConsumerDmaapModel expectedObject = ImmutableConsumerDmaapModel.builder() .ipv4("") .ipv6("0:0:0:0:0:FFFF:0A10:7BEA") @@ -446,7 +470,7 @@ class DmaapConsumerJsonParserTest { .equipVendor("nokia") .equipModel("3310") .equipType("type") - .nfRole("role") + .nfRole("gNB") .swVersion("v4.5.0.1") .build(); //when 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 a2f08078..87b037f1 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,23 +67,25 @@ class DmaapConsumerTaskImplTest { .equipVendor("nokia") .equipModel("3310") .equipType("type") - .nfRole("role") + .nfRole("gNB") .swVersion("v4.5.0.1") .build(); appConfig = mock(AppConfig.class); message = "[{\"event\": {" - + "\"commonEventHeader\": { \"sourceName\":\"NOKQTFCOC540002E\"}," + + "\"commonEventHeader\": { " + + " \"sourceName\":\"NOKQTFCOC540002E\"," + + " \"nfNamingCode\":\"gNB\" " + + "}," + "\"pnfRegistrationFields\": {" - + " \"equip-vendor\": \"nokia\"," - + " \"serial-number\": \"QTFCOC540002E\"," + + " \"vendorName\": \"nokia\"," + + " \"serialNumber\": \"QTFCOC540002E\"," + " \"pnfRegistrationFieldsVersion\": \"2.0\"," - + " \"equip-model\": \"3310\"," - + " \"equip-type\": \"type\",\n" - + " \"nf-role\": \"role\"," + + " \"modelNumber\": \"3310\"," + + " \"unitType\": \"type\",\n" + " \"unitFamily\": \"BBU\"," + " \"oamV4IpAddress\": \"10.16.123.234\"," - + " \"sw-version\": \"v4.5.0.1\"," + + " \"softwareVersion\": \"v4.5.0.1\"," + " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\"" + "}}}]"; } |