2  * ============LICENSE_START========================================================================
 
   3  * ONAP : ccsdk feature sdnr wt
 
   4  * =================================================================================================
 
   5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
 
   6  * =================================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 
   8  * in compliance with the License. You may obtain a copy of the License at
 
  10  * http://www.apache.org/licenses/LICENSE-2.0
 
  12  * Unless required by applicable law or agreed to in writing, software distributed under the License
 
  13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 
  14  * or implied. See the License for the specific language governing permissions and limitations under
 
  16  * ============LICENSE_END==========================================================================
 
  19 package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.consumer;
 
  21 import java.io.IOException;
 
  22 import org.junit.After;
 
  23 import org.junit.Before;
 
  24 import org.junit.Test;
 
  25 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config.GeneralConfigForTest;
 
  26 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.pnfreg.StrimziKafkaPNFRegVESMsgConsumer;
 
  28 public class TestStrimziKafkaPNFRegVESMsgConsumer {
 
  30     private static final String DEFAULT_SDNRUSER = "admin";
 
  31     private static final String DEFAULT_SDNRPASSWD = "admin";
 
  32     private static final String DEFAULT_SDNRBASEURL = "http://localhost:8181";
 
  33     private static final String CONFIGURATIONFILE = "test4.properties";
 
  36     private static final String pnfRegMsg_TLS = "{\n"
 
  38             + "    \"commonEventHeader\": {\n"
 
  39             + "      \"domain\": \"pnfRegistration\",\n"
 
  40             + "      \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n"
 
  41             + "      \"eventName\": \"pnfRegistration_EventType5G\",\n"
 
  42             + "      \"eventType\": \"EventType5G\",\n"
 
  43             + "      \"sequence\": 0,\n"
 
  44             + "      \"priority\": \"Low\",\n"
 
  45             + "      \"reportingEntityId\": \"\",\n"
 
  46             + "      \"reportingEntityName\": \"pendurty-virtual-machine\",\n"
 
  47             + "      \"sourceId\": \"\",\n"
 
  48             + "      \"sourceName\": \"NSHMRIACQ01M01123401\",\n"
 
  49             + "      \"startEpochMicrosec\": 1571300004203,\n"
 
  50             + "      \"lastEpochMicrosec\": 1571300004203,\n"
 
  51             + "      \"nfNamingCode\": \"1234\",\n"
 
  52             + "      \"nfVendorName\": \"VENDORA\",\n"
 
  53             + "      \"timeZoneOffset\": \"+00:00\",\n"
 
  54             + "      \"version\": \"4.0.1\",\n"
 
  55             + "      \"vesEventListenerVersion\":\"7.0.1\"\n"
 
  57             + "    \"pnfRegistrationFields\": {\n"
 
  58             + "      \"pnfRegistrationFieldsVersion\": \"2.0\",\n"
 
  59             + "         \"additionalFields\": \n"
 
  61             + "                 \"protocol\":\"TLS\",\n"
 
  62             + "                 \"keyId\":\"netconf\",\n"
 
  63             + "                 \"oamPort\":\"50000\",\n"
 
  64             + "                 \"betweenAttemptsTimeout\":\"2000\",\n"
 
  65             + "                 \"keepaliveDelay\":\"120\",\n"
 
  66             + "                 \"sleep-factor\":\"1.5\",\n"
 
  67             + "                 \"reconnectOnChangedSchema\":\"false\",\n"
 
  68             + "                 \"connectionTimeout\":\"20000\",\n"
 
  69             + "                 \"maxConnectionAttempts\":\"100\",\n"
 
  70             + "                 \"username\":\"netconf\",\n"
 
  71             + "                 \"tcpOnly\":\"false\"\n"
 
  73             + "      \"lastServiceDate\":\"2019-08-16\",\n"
 
  74             + "      \"macAddress\":\"02:42:f7:d4:62:ce\",\n"
 
  75             + "      \"manufactureDate\":\"2019-08-16\",\n"
 
  76             + "      \"modelNumbsdnrer\": \"1234 BestInClass\",\n"
 
  77             + "      \"oamV4IpAddress\": \"10.10.10.11\",\n"
 
  78             + "    \"oamPort\":\"17380\",\n"
 
  79             + "      \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n"
 
  80             + "      \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n"
 
  81             + "      \"softwareVersion\": \"2.3.5\",\n"
 
  82             + "      \"unitFamily\": \"VENDORA-1234\",\n"
 
  83             + "      \"unitType\": \"1234\",\n"
 
  84             + "      \"vendorName\": \"VENDORA\"\n"
 
  89     private static final String pnfRegMsg_SSH = "{\n"
 
  91             + "    \"commonEventHeader\": {\n"
 
  92             + "      \"domain\": \"pnfRegistration\",\n"
 
  93             + "      \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n"
 
  94             + "      \"eventName\": \"pnfRegistration_EventType5G\",\n"
 
  95             + "      \"eventType\": \"EventType5G\",\n"
 
  96             + "      \"sequence\": 0,\n"
 
  97             + "      \"priority\": \"Low\",\n"
 
  98             + "      \"reportingEntityId\": \"\",\n"
 
  99             + "      \"reportingEntityName\": \"pendurty-virtual-machine\",\n"
 
 100             + "      \"sourceId\": \"\",\n"
 
 101             + "      \"sourceName\": \"NSHMRIACQ01M01123401\",\n"
 
 102             + "      \"startEpochMicrosec\": 1571300004203,\n"
 
 103             + "      \"lastEpochMicrosec\": 1571300004203,\n"
 
 104             + "      \"nfNamingCode\": \"1234\",\n"
 
 105             + "      \"nfVendorName\": \"VENDORA\",\n"
 
 106             + "      \"timeZoneOffset\": \"+00:00\",\n"
 
 107             + "      \"version\": \"4.0.1\",\n"
 
 108             + "      \"vesEventListenerVersion\":\"7.0.1\"\n"
 
 110             + "    \"pnfRegistrationFields\": {\n"
 
 111             + "      \"pnfRegistrationFieldsVersion\": \"2.0\",\n"
 
 112             + "         \"additionalFields\": \n"
 
 114             + "                 \"protocol\":\"SSH\",\n"
 
 115             + "                 \"password\":\"netconf\",\n"
 
 116             + "                 \"oamPort\":\"50000\",\n"
 
 117             + "                 \"betweenAttemptsTimeout\":\"2000\",\n"
 
 118             + "                 \"keepaliveDelay\":\"120\",\n"
 
 119             + "                 \"sleep-factor\":\"1.5\",\n"
 
 120             + "                 \"reconnectOnChangedSchema\":\"false\",\n"
 
 121             + "                 \"connectionTimeout\":\"20000\",\n"
 
 122             + "                 \"maxConnectionAttempts\":\"100\",\n"
 
 123             + "                 \"username\":\"netconf\",\n"
 
 124             + "                 \"tcpOnly\":\"false\"\n"
 
 126             + "      \"lastServiceDate\":\"2019-08-16\",\n"
 
 127             + "      \"macAddress\":\"02:42:f7:d4:62:ce\",\n"
 
 128             + "      \"manufactureDate\":\"2019-08-16\",\n"
 
 129             + "      \"modelNumbsdnrer\": \"1234 BestInClass\",\n"
 
 130             + "      \"oamV4IpAddress\": \"10.10.10.11\",\n"
 
 131             + "    \"oamPort\":\"17380\",\n"
 
 132             + "      \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n"
 
 133             + "      \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n"
 
 134             + "      \"softwareVersion\": \"2.3.5\",\n"
 
 135             + "      \"unitFamily\": \"VENDORA-1234\",\n"
 
 136             + "      \"unitType\": \"1234\",\n"
 
 137             + "      \"vendorName\": \"VENDORA\"\n"
 
 142     private static final String pnfRegMsg_OTHER = "{\n"
 
 144             + "    \"commonEventHeader\": {\n"
 
 145             + "      \"domain\": \"pnfRegistration\",\n"
 
 146             + "      \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n"
 
 147             + "      \"eventName\": \"pnfRegistration_EventType5G\",\n"
 
 148             + "      \"eventType\": \"EventType5G\",\n"
 
 149             + "      \"sequence\": 0,\n"
 
 150             + "      \"priority\": \"Low\",\n"
 
 151             + "      \"reportingEntityId\": \"\",\n"
 
 152             + "      \"reportingEntityName\": \"pendurty-virtual-machine\",\n"
 
 153             + "      \"sourceId\": \"\",\n"
 
 154             + "      \"sourceName\": \"NSHMRIACQ01M01123401\",\n"
 
 155             + "      \"startEpochMicrosec\": 1571300004203,\n"
 
 156             + "      \"lastEpochMicrosec\": 1571300004203,\n"
 
 157             + "      \"nfNamingCode\": \"1234\",\n"
 
 158             + "      \"nfVendorName\": \"VENDORA\",\n"
 
 159             + "      \"timeZoneOffset\": \"+00:00\",\n"
 
 160             + "      \"version\": \"4.0.1\",\n"
 
 161             + "      \"vesEventListenerVersion\":\"7.0.1\"\n"
 
 163             + "    \"pnfRegistrationFields\": {\n"
 
 164             + "      \"pnfRegistrationFieldsVersion\": \"2.0\",\n"
 
 165             + "         \"additionalFields\": \n"
 
 167             + "                 \"protocol\":\"OTHER\",\n"
 
 168             + "                 \"password\":\"netconf\",\n"
 
 169             + "                 \"oamPort\":\"50000\",\n"
 
 170             + "                 \"betweenAttemptsTimeout\":\"2000\",\n"
 
 171             + "                 \"keepaliveDelay\":\"120\",\n"
 
 172             + "                 \"sleep-factor\":\"1.5\",\n"
 
 173             + "                 \"reconnectOnChangedSchema\":\"false\",\n"
 
 174             + "                 \"connectionTimeout\":\"20000\",\n"
 
 175             + "                 \"maxConnectionAttempts\":\"100\",\n"
 
 176             + "                 \"username\":\"netconf\",\n"
 
 177             + "                 \"tcpOnly\":\"false\"\n"
 
 179             + "      \"lastServiceDate\":\"2019-08-16\",\n"
 
 180             + "      \"macAddress\":\"02:42:f7:d4:62:ce\",\n"
 
 181             + "      \"manufactureDate\":\"2019-08-16\",\n"
 
 182             + "      \"modelNumbsdnrer\": \"1234 BestInClass\",\n"
 
 183             + "      \"oamV4IpAddress\": \"10.10.10.11\",\n"
 
 184             + "    \"oamPort\":\"17380\",\n"
 
 185             + "      \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n"
 
 186             + "      \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n"
 
 187             + "      \"softwareVersion\": \"2.3.5\",\n"
 
 188             + "      \"unitFamily\": \"VENDORA-1234\",\n"
 
 189             + "      \"unitType\": \"1234\",\n"
 
 190             + "      \"vendorName\": \"VENDORA\"\n"
 
 195     private static final String pnfRegMsg = "{\n"
 
 197             + "    \"commonEventHeader\": {\n"
 
 198             + "      \"domain\": \"pnfRegistration\",\n"
 
 199             + "      \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n"
 
 200             + "      \"eventName\": \"pnfRegistration_EventType5G\",\n"
 
 201             + "      \"eventType\": \"EventType5G\",\n"
 
 202             + "      \"sequence\": 0,\n"
 
 203             + "      \"priority\": \"Low\",\n"
 
 204             + "      \"reportingEntityId\": \"\",\n"
 
 205             + "      \"reportingEntityName\": \"pendurty-virtual-machine\",\n"
 
 206             + "      \"sourceId\": \"\",\n"
 
 207             + "      \"sourceName\": \"NSHMRIACQ01M01123401\",\n"
 
 208             + "      \"startEpochMicrosec\": 1571300004203,\n"
 
 209             + "      \"lastEpochMicrosec\": 1571300004203,\n"
 
 210             + "      \"nfNamingCode\": \"1234\",\n"
 
 211             + "      \"nfVendorName\": \"VENDORA\",\n"
 
 212             + "      \"timeZoneOffset\": \"+00:00\",\n"
 
 213             + "      \"version\": \"4.0.1\",\n"
 
 214             + "      \"vesEventListenerVersion\":\"7.0.1\"\n"
 
 216             + "    \"pnfRegistrationFields\": {\n"
 
 217             + "      \"pnfRegistrationFieldsVersion\": \"2.0\",\n"
 
 218             + "      \"lastServiceDate\":\"2019-08-16\",\n"
 
 219             + "      \"macAddress\":\"02:42:f7:d4:62:ce\",\n"
 
 220             + "      \"manufactureDate\":\"2019-08-16\",\n"
 
 221             + "      \"modelNumbsdnrer\": \"1234 BestInClass\",\n"
 
 222             + "      \"oamV4IpAddress\": \"10.10.10.11\",\n"
 
 223             + "    \"oamPort\":\"17380\",\n"
 
 224             //+ "      \"oamV6IpAddress\": \"\",\n"
 
 225             + "      \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n"
 
 226             + "      \"softwareVersion\": \"2.3.5\",\n"
 
 227             + "      \"unitFamily\": \"VENDORA-1234\",\n"
 
 228             + "      \"unitType\": \"1234\",\n"
 
 229             + "      \"vendorName\": \"VENDORA\"\n"
 
 236     private GeneralConfigForTest cfgTest;
 
 239     public void before() throws IOException {
 
 240         cfgTest = new GeneralConfigForTest(CONFIGURATIONFILE);
 
 244     public void after() {
 
 249     public void processMsgTest() {
 
 251         StrimziKafkaPNFRegVESMsgConsumer pnfRegMsgConsumer = new StrimziKafkaPNFRegVESMsgConsumer(cfgTest.getCfg());
 
 253             pnfRegMsgConsumer.processMsg(pnfRegMsg);
 
 254             pnfRegMsgConsumer.processMsg(pnfRegMsg_SSH);
 
 255             pnfRegMsgConsumer.processMsg(pnfRegMsg_TLS);
 
 256             pnfRegMsgConsumer.processMsg(pnfRegMsg_OTHER);
 
 257         } catch (Exception e) {
 
 259             System.out.println("Exception while processing PNF Registration Message - " + e.getMessage());
 
 264     public void Test1() {
 
 265         StrimziKafkaPNFRegVESMsgConsumer pnfConsumer = new StrimziKafkaPNFRegVESMsgConsumer(cfgTest.getCfg());
 
 266         System.out.println(pnfConsumer.getBaseUrl());
 
 267         System.out.println(pnfConsumer.getSDNRUser());
 
 268         System.out.println(pnfConsumer.getSDNRPasswd());