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;
21 import org.junit.Test;
22 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer;
23 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.PNFMountPointClient;
25 public class TestDMaaPPNFRegVESMsgConsumer extends DMaaPPNFRegVESMsgConsumer {
27 private static final String DEFAULT_SDNRUSER = "admin";
28 private static final String DEFAULT_SDNRPASSWD = "admin";
29 private static final String DEFAULT_SDNRBASEURL = "http://localhost:8181";
32 private static final String pnfRegMsg_TLS = "{\n"
34 + " \"commonEventHeader\": {\n"
35 + " \"domain\": \"pnfRegistration\",\n"
36 + " \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n"
37 + " \"eventName\": \"pnfRegistration_EventType5G\",\n"
38 + " \"eventType\": \"EventType5G\",\n"
39 + " \"sequence\": 0,\n"
40 + " \"priority\": \"Low\",\n"
41 + " \"reportingEntityId\": \"\",\n"
42 + " \"reportingEntityName\": \"pendurty-virtual-machine\",\n"
43 + " \"sourceId\": \"\",\n"
44 + " \"sourceName\": \"NSHMRIACQ01M01123401\",\n"
45 + " \"startEpochMicrosec\": 1571300004203,\n"
46 + " \"lastEpochMicrosec\": 1571300004203,\n"
47 + " \"nfNamingCode\": \"1234\",\n"
48 + " \"nfVendorName\": \"VENDORA\",\n"
49 + " \"timeZoneOffset\": \"+00:00\",\n"
50 + " \"version\": \"4.0.1\",\n"
51 + " \"vesEventListenerVersion\":\"7.0.1\"\n"
53 + " \"pnfRegistrationFields\": {\n"
54 + " \"pnfRegistrationFieldsVersion\": \"2.0\",\n"
55 + " \"additionalFields\": \n"
57 + " \"protocol\":\"TLS\",\n"
58 + " \"keyId\":\"netconf\",\n"
59 + " \"oamPort\":\"50000\",\n"
60 + " \"betweenAttemptsTimeout\":\"2000\",\n"
61 + " \"keepaliveDelay\":\"120\",\n"
62 + " \"sleep-factor\":\"1.5\",\n"
63 + " \"reconnectOnChangedSchema\":\"false\",\n"
64 + " \"connectionTimeout\":\"20000\",\n"
65 + " \"maxConnectionAttempts\":\"100\",\n"
66 + " \"username\":\"netconf\",\n"
67 + " \"tcpOnly\":\"false\"\n"
69 + " \"lastServiceDate\":\"2019-08-16\",\n"
70 + " \"macAddress\":\"02:42:f7:d4:62:ce\",\n"
71 + " \"manufactureDate\":\"2019-08-16\",\n"
72 + " \"modelNumbsdnrer\": \"1234 BestInClass\",\n"
73 + " \"oamV4IpAddress\": \"10.10.10.11\",\n"
74 + " \"oamPort\":\"17380\",\n"
75 + " \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n"
76 + " \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n"
77 + " \"softwareVersion\": \"2.3.5\",\n"
78 + " \"unitFamily\": \"VENDORA-1234\",\n"
79 + " \"unitType\": \"1234\",\n"
80 + " \"vendorName\": \"VENDORA\"\n"
86 private static final String pnfRegMsg_SSH = "{\n"
88 + " \"commonEventHeader\": {\n"
89 + " \"domain\": \"pnfRegistration\",\n"
90 + " \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n"
91 + " \"eventName\": \"pnfRegistration_EventType5G\",\n"
92 + " \"eventType\": \"EventType5G\",\n"
93 + " \"sequence\": 0,\n"
94 + " \"priority\": \"Low\",\n"
95 + " \"reportingEntityId\": \"\",\n"
96 + " \"reportingEntityName\": \"pendurty-virtual-machine\",\n"
97 + " \"sourceId\": \"\",\n"
98 + " \"sourceName\": \"NSHMRIACQ01M01123401\",\n"
99 + " \"startEpochMicrosec\": 1571300004203,\n"
100 + " \"lastEpochMicrosec\": 1571300004203,\n"
101 + " \"nfNamingCode\": \"1234\",\n"
102 + " \"nfVendorName\": \"VENDORA\",\n"
103 + " \"timeZoneOffset\": \"+00:00\",\n"
104 + " \"version\": \"4.0.1\",\n"
105 + " \"vesEventListenerVersion\":\"7.0.1\"\n"
107 + " \"pnfRegistrationFields\": {\n"
108 + " \"pnfRegistrationFieldsVersion\": \"2.0\",\n"
109 + " \"additionalFields\": \n"
111 + " \"protocol\":\"SSH\",\n"
112 + " \"password\":\"netconf\",\n"
113 + " \"oamPort\":\"50000\",\n"
114 + " \"betweenAttemptsTimeout\":\"2000\",\n"
115 + " \"keepaliveDelay\":\"120\",\n"
116 + " \"sleep-factor\":\"1.5\",\n"
117 + " \"reconnectOnChangedSchema\":\"false\",\n"
118 + " \"connectionTimeout\":\"20000\",\n"
119 + " \"maxConnectionAttempts\":\"100\",\n"
120 + " \"username\":\"netconf\",\n"
121 + " \"tcpOnly\":\"false\"\n"
123 + " \"lastServiceDate\":\"2019-08-16\",\n"
124 + " \"macAddress\":\"02:42:f7:d4:62:ce\",\n"
125 + " \"manufactureDate\":\"2019-08-16\",\n"
126 + " \"modelNumbsdnrer\": \"1234 BestInClass\",\n"
127 + " \"oamV4IpAddress\": \"10.10.10.11\",\n"
128 + " \"oamPort\":\"17380\",\n"
129 + " \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n"
130 + " \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n"
131 + " \"softwareVersion\": \"2.3.5\",\n"
132 + " \"unitFamily\": \"VENDORA-1234\",\n"
133 + " \"unitType\": \"1234\",\n"
134 + " \"vendorName\": \"VENDORA\"\n"
140 private static final String pnfRegMsg_OTHER = "{\n"
142 + " \"commonEventHeader\": {\n"
143 + " \"domain\": \"pnfRegistration\",\n"
144 + " \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n"
145 + " \"eventName\": \"pnfRegistration_EventType5G\",\n"
146 + " \"eventType\": \"EventType5G\",\n"
147 + " \"sequence\": 0,\n"
148 + " \"priority\": \"Low\",\n"
149 + " \"reportingEntityId\": \"\",\n"
150 + " \"reportingEntityName\": \"pendurty-virtual-machine\",\n"
151 + " \"sourceId\": \"\",\n"
152 + " \"sourceName\": \"NSHMRIACQ01M01123401\",\n"
153 + " \"startEpochMicrosec\": 1571300004203,\n"
154 + " \"lastEpochMicrosec\": 1571300004203,\n"
155 + " \"nfNamingCode\": \"1234\",\n"
156 + " \"nfVendorName\": \"VENDORA\",\n"
157 + " \"timeZoneOffset\": \"+00:00\",\n"
158 + " \"version\": \"4.0.1\",\n"
159 + " \"vesEventListenerVersion\":\"7.0.1\"\n"
161 + " \"pnfRegistrationFields\": {\n"
162 + " \"pnfRegistrationFieldsVersion\": \"2.0\",\n"
163 + " \"additionalFields\": \n"
165 + " \"protocol\":\"OTHER\",\n"
166 + " \"password\":\"netconf\",\n"
167 + " \"oamPort\":\"50000\",\n"
168 + " \"betweenAttemptsTimeout\":\"2000\",\n"
169 + " \"keepaliveDelay\":\"120\",\n"
170 + " \"sleep-factor\":\"1.5\",\n"
171 + " \"reconnectOnChangedSchema\":\"false\",\n"
172 + " \"connectionTimeout\":\"20000\",\n"
173 + " \"maxConnectionAttempts\":\"100\",\n"
174 + " \"username\":\"netconf\",\n"
175 + " \"tcpOnly\":\"false\"\n"
177 + " \"lastServiceDate\":\"2019-08-16\",\n"
178 + " \"macAddress\":\"02:42:f7:d4:62:ce\",\n"
179 + " \"manufactureDate\":\"2019-08-16\",\n"
180 + " \"modelNumbsdnrer\": \"1234 BestInClass\",\n"
181 + " \"oamV4IpAddress\": \"10.10.10.11\",\n"
182 + " \"oamPort\":\"17380\",\n"
183 + " \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n"
184 + " \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n"
185 + " \"softwareVersion\": \"2.3.5\",\n"
186 + " \"unitFamily\": \"VENDORA-1234\",\n"
187 + " \"unitType\": \"1234\",\n"
188 + " \"vendorName\": \"VENDORA\"\n"
193 private static final String pnfRegMsg = "{\n"
195 + " \"commonEventHeader\": {\n"
196 + " \"domain\": \"pnfRegistration\",\n"
197 + " \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n"
198 + " \"eventName\": \"pnfRegistration_EventType5G\",\n"
199 + " \"eventType\": \"EventType5G\",\n"
200 + " \"sequence\": 0,\n"
201 + " \"priority\": \"Low\",\n"
202 + " \"reportingEntityId\": \"\",\n"
203 + " \"reportingEntityName\": \"pendurty-virtual-machine\",\n"
204 + " \"sourceId\": \"\",\n"
205 + " \"sourceName\": \"NSHMRIACQ01M01123401\",\n"
206 + " \"startEpochMicrosec\": 1571300004203,\n"
207 + " \"lastEpochMicrosec\": 1571300004203,\n"
208 + " \"nfNamingCode\": \"1234\",\n"
209 + " \"nfVendorName\": \"VENDORA\",\n"
210 + " \"timeZoneOffset\": \"+00:00\",\n"
211 + " \"version\": \"4.0.1\",\n"
212 + " \"vesEventListenerVersion\":\"7.0.1\"\n"
214 + " \"pnfRegistrationFields\": {\n"
215 + " \"pnfRegistrationFieldsVersion\": \"2.0\",\n"
216 + " \"lastServiceDate\":\"2019-08-16\",\n"
217 + " \"macAddress\":\"02:42:f7:d4:62:ce\",\n"
218 + " \"manufactureDate\":\"2019-08-16\",\n"
219 + " \"modelNumbsdnrer\": \"1234 BestInClass\",\n"
220 + " \"oamV4IpAddress\": \"10.10.10.11\",\n"
221 + " \"oamPort\":\"17380\",\n"
222 + " \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n"
223 + " \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n"
224 + " \"softwareVersion\": \"2.3.5\",\n"
225 + " \"unitFamily\": \"VENDORA-1234\",\n"
226 + " \"unitType\": \"1234\",\n"
227 + " \"vendorName\": \"VENDORA\"\n"
235 public void processMsgTest() {
237 DMaaPPNFRegVESMsgConsumer pnfRegMsgConsumer = new TestDMaaPPNFRegVESMsgConsumer();
239 pnfRegMsgConsumer.processMsg(pnfRegMsg);
240 pnfRegMsgConsumer.processMsg(pnfRegMsg_SSH);
241 pnfRegMsgConsumer.processMsg(pnfRegMsg_TLS);
242 pnfRegMsgConsumer.processMsg(pnfRegMsg_OTHER);
243 } catch (Exception e) {
245 System.out.println("Exception while processing PNF Registration Message - " + e.getMessage());
250 public PNFMountPointClient getPNFMountPointClient(String baseUrl) {
251 return new TestPNFMountPointClient();
255 public String getSDNRUser() {
256 return DEFAULT_SDNRUSER;
260 public String getSDNRPasswd() {
261 return DEFAULT_SDNRPASSWD;
265 public String getBaseUrl() {
266 return DEFAULT_SDNRBASEURL;
270 public void Test1() {
271 TestGeneralConfig cfgTest = new TestGeneralConfig();
273 DMaaPPNFRegVESMsgConsumer pnfConsumer = new DMaaPPNFRegVESMsgConsumer();
274 System.out.println(pnfConsumer.getBaseUrl());
275 System.out.println(pnfConsumer.getSDNRUser());
276 System.out.println(pnfConsumer.getSDNRPasswd());