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.After;
22 import org.junit.Before;
23 import org.junit.Test;
25 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer;
26 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.PNFMountPointClient;
28 public class TestDMaaPPNFRegVESMsgConsumer extends DMaaPPNFRegVESMsgConsumer {
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";
34 private static final String pnfRegMsg_TLS = "{\n" +
36 " \"commonEventHeader\": {\n" +
37 " \"domain\": \"pnfRegistration\",\n" +
38 " \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n" +
39 " \"eventName\": \"pnfRegistration_EventType5G\",\n" +
40 " \"eventType\": \"EventType5G\",\n" +
41 " \"sequence\": 0,\n" +
42 " \"priority\": \"Low\",\n" +
43 " \"reportingEntityId\": \"\",\n" +
44 " \"reportingEntityName\": \"pendurty-virtual-machine\",\n" +
45 " \"sourceId\": \"\",\n" +
46 " \"sourceName\": \"NSHMRIACQ01M01123401\",\n" +
47 " \"startEpochMicrosec\": 1571300004203,\n" +
48 " \"lastEpochMicrosec\": 1571300004203,\n" +
49 " \"nfNamingCode\": \"1234\",\n" +
50 " \"nfVendorName\": \"VENDORA\",\n" +
51 " \"timeZoneOffset\": \"+00:00\",\n" +
52 " \"version\": \"4.0.1\",\n" +
53 " \"vesEventListenerVersion\":\"7.0.1\"\n" +
55 " \"pnfRegistrationFields\": {\n" +
56 " \"pnfRegistrationFieldsVersion\": \"2.0\",\n" +
57 " \"additionalFields\": \n" +
59 " \"protocol\":\"TLS\",\n"+
60 " \"keyId\":\"netconf\",\n"+
61 " \"oamPort\":\"50000\",\n"+
62 " \"betweenAttemptsTimeout\":\"2000\",\n" +
63 " \"keepaliveDelay\":\"120\",\n" +
64 " \"sleep-factor\":\"1.5\",\n" +
65 " \"reconnectOnChangedSchema\":\"false\",\n" +
66 " \"connectionTimeout\":\"20000\",\n" +
67 " \"maxConnectionAttempts\":\"100\",\n" +
68 " \"username\":\"netconf\",\n" +
69 " \"tcpOnly\":\"false\"\n" +
71 " \"lastServiceDate\":\"2019-08-16\",\n" +
72 " \"macAddress\":\"02:42:f7:d4:62:ce\",\n" +
73 " \"manufactureDate\":\"2019-08-16\",\n" +
74 " \"modelNumbsdnrer\": \"1234 BestInClass\",\n" +
75 " \"oamV4IpAddress\": \"10.10.10.11\",\n" +
76 " \"oamPort\":\"17380\",\n" +
77 " \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n" +
78 " \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n" +
79 " \"softwareVersion\": \"2.3.5\",\n" +
80 " \"unitFamily\": \"VENDORA-1234\",\n" +
81 " \"unitType\": \"1234\",\n" +
82 " \"vendorName\": \"VENDORA\"\n" +
88 private static final String pnfRegMsg_SSH = "{\n" +
90 " \"commonEventHeader\": {\n" +
91 " \"domain\": \"pnfRegistration\",\n" +
92 " \"eventId\": \"NSHMRIACQ01M01123401_1234 BestInClass\",\n" +
93 " \"eventName\": \"pnfRegistration_EventType5G\",\n" +
94 " \"eventType\": \"EventType5G\",\n" +
95 " \"sequence\": 0,\n" +
96 " \"priority\": \"Low\",\n" +
97 " \"reportingEntityId\": \"\",\n" +
98 " \"reportingEntityName\": \"pendurty-virtual-machine\",\n" +
99 " \"sourceId\": \"\",\n" +
100 " \"sourceName\": \"NSHMRIACQ01M01123401\",\n" +
101 " \"startEpochMicrosec\": 1571300004203,\n" +
102 " \"lastEpochMicrosec\": 1571300004203,\n" +
103 " \"nfNamingCode\": \"1234\",\n" +
104 " \"nfVendorName\": \"VENDORA\",\n" +
105 " \"timeZoneOffset\": \"+00:00\",\n" +
106 " \"version\": \"4.0.1\",\n" +
107 " \"vesEventListenerVersion\":\"7.0.1\"\n" +
109 " \"pnfRegistrationFields\": {\n" +
110 " \"pnfRegistrationFieldsVersion\": \"2.0\",\n" +
111 " \"additionalFields\": \n" +
113 " \"protocol\":\"SSH\",\n"+
114 " \"password\":\"netconf\",\n"+
115 " \"oamPort\":\"50000\",\n"+
116 " \"betweenAttemptsTimeout\":\"2000\",\n" +
117 " \"keepaliveDelay\":\"120\",\n" +
118 " \"sleep-factor\":\"1.5\",\n" +
119 " \"reconnectOnChangedSchema\":\"false\",\n" +
120 " \"connectionTimeout\":\"20000\",\n" +
121 " \"maxConnectionAttempts\":\"100\",\n" +
122 " \"username\":\"netconf\",\n" +
123 " \"tcpOnly\":\"false\"\n" +
125 " \"lastServiceDate\":\"2019-08-16\",\n" +
126 " \"macAddress\":\"02:42:f7:d4:62:ce\",\n" +
127 " \"manufactureDate\":\"2019-08-16\",\n" +
128 " \"modelNumbsdnrer\": \"1234 BestInClass\",\n" +
129 " \"oamV4IpAddress\": \"10.10.10.11\",\n" +
130 " \"oamPort\":\"17380\",\n" +
131 " \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n" +
132 " \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n" +
133 " \"softwareVersion\": \"2.3.5\",\n" +
134 " \"unitFamily\": \"VENDORA-1234\",\n" +
135 " \"unitType\": \"1234\",\n" +
136 " \"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\": \"0:0:0:0:0:ffff:a0a:011\",\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 public void processMsgTest() {
238 DMaaPPNFRegVESMsgConsumer pnfRegMsgConsumer = new TestDMaaPPNFRegVESMsgConsumer();
240 pnfRegMsgConsumer.processMsg(pnfRegMsg);
241 pnfRegMsgConsumer.processMsg(pnfRegMsg_SSH);
242 pnfRegMsgConsumer.processMsg(pnfRegMsg_TLS);
243 pnfRegMsgConsumer.processMsg(pnfRegMsg_OTHER);
244 } catch (Exception e) {
246 System.out.println("Exception while processing PNF Registration Message - "+e.getMessage());
251 public PNFMountPointClient getPNFMountPointClient(String baseUrl) {
252 return new TestPNFMountPointClient();
256 public String getSDNRUser() {
257 return DEFAULT_SDNRUSER;
261 public String getSDNRPasswd() {
262 return DEFAULT_SDNRPASSWD;
266 public String getBaseUrl() {
267 return DEFAULT_SDNRBASEURL;
271 public void Test1() {
272 TestGeneralConfig cfgTest = new TestGeneralConfig();
274 DMaaPPNFRegVESMsgConsumer pnfConsumer = new DMaaPPNFRegVESMsgConsumer();
275 System.out.println(pnfConsumer.getBaseUrl());
276 System.out.println(pnfConsumer.getSDNRUser());
277 System.out.println(pnfConsumer.getSDNRPasswd());