diff options
author | pwielebs <piotr.wielebski@nokia.com> | 2018-08-30 12:02:31 +0200 |
---|---|---|
committer | pwielebs <piotr.wielebski@nokia.com> | 2018-08-30 12:02:31 +0200 |
commit | ed4d45332691282e7e0dc4bb413d20f46e1a0a66 (patch) | |
tree | 5bb2c06ef453ae8868cbd0f1b04ce9375c165459 /prh-app-server/src/test/java/org | |
parent | 4fbb9e8ad097c9ec3c3434ba257e887fb3a64699 (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>
Diffstat (limited to 'prh-app-server/src/test/java/org')
4 files changed, 126 insertions, 40 deletions
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); } |