1 /*******************************************************************************
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==========================================================================
17 ******************************************************************************/
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";
31 private static final String pnfRegMsg_TLS = "{\n" +
33 " \"commonEventHeader\": {\n" +
34 " \"domain\": \"pnfRegistration\",\n" +
35 " \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n" +
36 " \"eventName\": \"pnfRegistration_EventType5G\",\n" +
37 " \"eventType\": \"EventType5G\",\n" +
38 " \"sequence\": 0,\n" +
39 " \"priority\": \"Low\",\n" +
40 " \"reportingEntityId\": \"\",\n" +
41 " \"reportingEntityName\": \"pendurty-virtual-machine\",\n" +
42 " \"sourceId\": \"\",\n" +
43 " \"sourceName\": \"NSHMRIACQ01M01123401\",\n" +
44 " \"startEpochMicrosec\": 1571300004203,\n" +
45 " \"lastEpochMicrosec\": 1571300004203,\n" +
46 " \"nfNamingCode\": \"1234\",\n" +
47 " \"nfVendorName\": \"VENDORA\",\n" +
48 " \"timeZoneOffset\": \"+00:00\",\n" +
49 " \"version\": \"4.0.1\",\n" +
50 " \"vesEventListenerVersion\":\"7.0.1\"\n" +
52 " \"pnfRegistrationFields\": {\n" +
53 " \"pnfRegistrationFieldsVersion\": \"2.0\",\n" +
54 " \"additionalFields\": \n" +
56 " \"protocol\":\"TLS\",\n"+
57 " \"keyId\":\"netconf\",\n"+
58 " \"oamPort\":\"50000\",\n"+
59 " \"betweenAttemptsTimeout\":\"2000\",\n" +
60 " \"keepaliveDelay\":\"120\",\n" +
61 " \"sleep-factor\":\"1.5\",\n" +
62 " \"reconnectOnChangedSchema\":\"false\",\n" +
63 " \"connectionTimeout\":\"20000\",\n" +
64 " \"maxConnectionAttempts\":\"100\",\n" +
65 " \"username\":\"netconf\",\n" +
66 " \"tcpOnly\":\"false\"\n" +
68 " \"lastServiceDate\":\"2019-08-16\",\n" +
69 " \"macAddress\":\"02:42:f7:d4:62:ce\",\n" +
70 " \"manufactureDate\":\"2019-08-16\",\n" +
71 " \"modelNumbsdnrer\": \"1234 BestInClass\",\n" +
72 " \"oamV4IpAddress\": \"10.10.10.11\",\n" +
73 " \"oamPort\":\"17380\",\n" +
74 " \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n" +
75 " \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n" +
76 " \"softwareVersion\": \"2.3.5\",\n" +
77 " \"unitFamily\": \"VENDORA-1234\",\n" +
78 " \"unitType\": \"1234\",\n" +
79 " \"vendorName\": \"VENDORA\"\n" +
85 private static final String pnfRegMsg_SSH = "{\n" +
87 " \"commonEventHeader\": {\n" +
88 " \"domain\": \"pnfRegistration\",\n" +
89 " \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n" +
90 " \"eventName\": \"pnfRegistration_EventType5G\",\n" +
91 " \"eventType\": \"EventType5G\",\n" +
92 " \"sequence\": 0,\n" +
93 " \"priority\": \"Low\",\n" +
94 " \"reportingEntityId\": \"\",\n" +
95 " \"reportingEntityName\": \"pendurty-virtual-machine\",\n" +
96 " \"sourceId\": \"\",\n" +
97 " \"sourceName\": \"NSHMRIACQ01M01123401\",\n" +
98 " \"startEpochMicrosec\": 1571300004203,\n" +
99 " \"lastEpochMicrosec\": 1571300004203,\n" +
100 " \"nfNamingCode\": \"1234\",\n" +
101 " \"nfVendorName\": \"VENDORA\",\n" +
102 " \"timeZoneOffset\": \"+00:00\",\n" +
103 " \"version\": \"4.0.1\",\n" +
104 " \"vesEventListenerVersion\":\"7.0.1\"\n" +
106 " \"pnfRegistrationFields\": {\n" +
107 " \"pnfRegistrationFieldsVersion\": \"2.0\",\n" +
108 " \"additionalFields\": \n" +
110 " \"protocol\":\"SSH\",\n"+
111 " \"password\":\"netconf\",\n"+
112 " \"oamPort\":\"50000\",\n"+
113 " \"betweenAttemptsTimeout\":\"2000\",\n" +
114 " \"keepaliveDelay\":\"120\",\n" +
115 " \"sleep-factor\":\"1.5\",\n" +
116 " \"reconnectOnChangedSchema\":\"false\",\n" +
117 " \"connectionTimeout\":\"20000\",\n" +
118 " \"maxConnectionAttempts\":\"100\",\n" +
119 " \"username\":\"netconf\",\n" +
120 " \"tcpOnly\":\"false\"\n" +
122 " \"lastServiceDate\":\"2019-08-16\",\n" +
123 " \"macAddress\":\"02:42:f7:d4:62:ce\",\n" +
124 " \"manufactureDate\":\"2019-08-16\",\n" +
125 " \"modelNumbsdnrer\": \"1234 BestInClass\",\n" +
126 " \"oamV4IpAddress\": \"10.10.10.11\",\n" +
127 " \"oamPort\":\"17380\",\n" +
128 " \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n" +
129 " \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n" +
130 " \"softwareVersion\": \"2.3.5\",\n" +
131 " \"unitFamily\": \"VENDORA-1234\",\n" +
132 " \"unitType\": \"1234\",\n" +
133 " \"vendorName\": \"VENDORA\"\n" +
139 private static final String pnfRegMsg_OTHER = "{\n" +
141 " \"commonEventHeader\": {\n" +
142 " \"domain\": \"pnfRegistration\",\n" +
143 " \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n" +
144 " \"eventName\": \"pnfRegistration_EventType5G\",\n" +
145 " \"eventType\": \"EventType5G\",\n" +
146 " \"sequence\": 0,\n" +
147 " \"priority\": \"Low\",\n" +
148 " \"reportingEntityId\": \"\",\n" +
149 " \"reportingEntityName\": \"pendurty-virtual-machine\",\n" +
150 " \"sourceId\": \"\",\n" +
151 " \"sourceName\": \"NSHMRIACQ01M01123401\",\n" +
152 " \"startEpochMicrosec\": 1571300004203,\n" +
153 " \"lastEpochMicrosec\": 1571300004203,\n" +
154 " \"nfNamingCode\": \"1234\",\n" +
155 " \"nfVendorName\": \"VENDORA\",\n" +
156 " \"timeZoneOffset\": \"+00:00\",\n" +
157 " \"version\": \"4.0.1\",\n" +
158 " \"vesEventListenerVersion\":\"7.0.1\"\n" +
160 " \"pnfRegistrationFields\": {\n" +
161 " \"pnfRegistrationFieldsVersion\": \"2.0\",\n" +
162 " \"additionalFields\": \n" +
164 " \"protocol\":\"OTHER\",\n"+
165 " \"password\":\"netconf\",\n"+
166 " \"oamPort\":\"50000\",\n"+
167 " \"betweenAttemptsTimeout\":\"2000\",\n" +
168 " \"keepaliveDelay\":\"120\",\n" +
169 " \"sleep-factor\":\"1.5\",\n" +
170 " \"reconnectOnChangedSchema\":\"false\",\n" +
171 " \"connectionTimeout\":\"20000\",\n" +
172 " \"maxConnectionAttempts\":\"100\",\n" +
173 " \"username\":\"netconf\",\n" +
174 " \"tcpOnly\":\"false\"\n" +
176 " \"lastServiceDate\":\"2019-08-16\",\n" +
177 " \"macAddress\":\"02:42:f7:d4:62:ce\",\n" +
178 " \"manufactureDate\":\"2019-08-16\",\n" +
179 " \"modelNumbsdnrer\": \"1234 BestInClass\",\n" +
180 " \"oamV4IpAddress\": \"10.10.10.11\",\n" +
181 " \"oamPort\":\"17380\",\n" +
182 " \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n" +
183 " \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n" +
184 " \"softwareVersion\": \"2.3.5\",\n" +
185 " \"unitFamily\": \"VENDORA-1234\",\n" +
186 " \"unitType\": \"1234\",\n" +
187 " \"vendorName\": \"VENDORA\"\n" +
192 private static final String pnfRegMsg = "{\n" +
194 " \"commonEventHeader\": {\n" +
195 " \"domain\": \"pnfRegistration\",\n" +
196 " \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n" +
197 " \"eventName\": \"pnfRegistration_EventType5G\",\n" +
198 " \"eventType\": \"EventType5G\",\n" +
199 " \"sequence\": 0,\n" +
200 " \"priority\": \"Low\",\n" +
201 " \"reportingEntityId\": \"\",\n" +
202 " \"reportingEntityName\": \"pendurty-virtual-machine\",\n" +
203 " \"sourceId\": \"\",\n" +
204 " \"sourceName\": \"NSHMRIACQ01M01123401\",\n" +
205 " \"startEpochMicrosec\": 1571300004203,\n" +
206 " \"lastEpochMicrosec\": 1571300004203,\n" +
207 " \"nfNamingCode\": \"1234\",\n" +
208 " \"nfVendorName\": \"VENDORA\",\n" +
209 " \"timeZoneOffset\": \"+00:00\",\n" +
210 " \"version\": \"4.0.1\",\n" +
211 " \"vesEventListenerVersion\":\"7.0.1\"\n" +
213 " \"pnfRegistrationFields\": {\n" +
214 " \"pnfRegistrationFieldsVersion\": \"2.0\",\n" +
215 " \"lastServiceDate\":\"2019-08-16\",\n" +
216 " \"macAddress\":\"02:42:f7:d4:62:ce\",\n" +
217 " \"manufactureDate\":\"2019-08-16\",\n" +
218 " \"modelNumbsdnrer\": \"1234 BestInClass\",\n" +
219 " \"oamV4IpAddress\": \"10.10.10.11\",\n" +
220 " \"oamPort\":\"17380\",\n" +
221 " \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n" +
222 " \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n" +
223 " \"softwareVersion\": \"2.3.5\",\n" +
224 " \"unitFamily\": \"VENDORA-1234\",\n" +
225 " \"unitType\": \"1234\",\n" +
226 " \"vendorName\": \"VENDORA\"\n" +
233 public void processMsgTest() {
235 DMaaPPNFRegVESMsgConsumer pnfRegMsgConsumer = new TestDMaaPPNFRegVESMsgConsumer();
237 pnfRegMsgConsumer.processMsg(pnfRegMsg);
238 pnfRegMsgConsumer.processMsg(pnfRegMsg_SSH);
239 pnfRegMsgConsumer.processMsg(pnfRegMsg_TLS);
240 pnfRegMsgConsumer.processMsg(pnfRegMsg_OTHER);
241 } catch (Exception e) {
243 System.out.println("Exception while processing PNF Registration Message - "+e.getMessage());
248 public PNFMountPointClient getPNFMountPointClient(String baseUrl) {
249 return new TestPNFMountPointClient();
253 public String getSDNRUser() {
254 return DEFAULT_SDNRUSER;
258 public String getSDNRPasswd() {
259 return DEFAULT_SDNRPASSWD;
263 public String getBaseUrl() {
264 return DEFAULT_SDNRBASEURL;
268 public void Test1() {
269 TestGeneralConfig cfgTest = new TestGeneralConfig();
271 DMaaPPNFRegVESMsgConsumer pnfConsumer = new DMaaPPNFRegVESMsgConsumer();
272 System.out.println(pnfConsumer.getBaseUrl());
273 System.out.println(pnfConsumer.getSDNRUser());
274 System.out.println(pnfConsumer.getSDNRPasswd());