54439150c953f2d8ce5e95a9a9a19752eda2c02a
[ccsdk/features.git] /
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18
19 package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test;
20
21 import org.junit.After;
22 import org.junit.Before;
23 import org.junit.Test;
24
25 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer;
26 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.PNFMountPointClient;
27
28 public class TestDMaaPPNFRegVESMsgConsumer extends DMaaPPNFRegVESMsgConsumer {
29
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         
34         private static final String pnfRegMsg_TLS = "{\n" + 
35                         "  \"event\": {\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" + 
54                         "    },\n" + 
55                         "    \"pnfRegistrationFields\": {\n" + 
56                         "      \"pnfRegistrationFieldsVersion\": \"2.0\",\n" + 
57                         "               \"additionalFields\": \n" +
58                         "               { \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" +
70                         "               },\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" + 
83                         "    }\n" + 
84                         "  }\n" + 
85                         "}\n" + 
86                         "";
87         
88         private static final String pnfRegMsg_SSH = "{\n" + 
89                         "  \"event\": {\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" + 
108                         "    },\n" + 
109                         "    \"pnfRegistrationFields\": {\n" + 
110                         "      \"pnfRegistrationFieldsVersion\": \"2.0\",\n" + 
111                         "               \"additionalFields\": \n" +
112                         "               { \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" +
124                         "               },\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" + 
137                         "    }\n" + 
138                         "  }\n" + 
139                         "}\n" + 
140                         "";
141
142         private static final String pnfRegMsg_OTHER = "{\n" + 
143                         "  \"event\": {\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" + 
162                         "    },\n" + 
163                         "    \"pnfRegistrationFields\": {\n" + 
164                         "      \"pnfRegistrationFieldsVersion\": \"2.0\",\n" + 
165                         "               \"additionalFields\": \n" +
166                         "               { \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" +
178                         "               },\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" + 
191                         "    }\n" + 
192                         "  }\n" + 
193                         "}\n" + 
194                         "";
195         private static final String pnfRegMsg = "{\n" + 
196                         "  \"event\": {\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" + 
215                         "    },\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" + 
230                         "    }\n" + 
231                         "  }\n" + 
232                         "}\n" + 
233                         "";
234         
235         @Test
236         public void processMsgTest() {
237                 
238                 DMaaPPNFRegVESMsgConsumer pnfRegMsgConsumer = new TestDMaaPPNFRegVESMsgConsumer();
239                 try {
240                         pnfRegMsgConsumer.processMsg(pnfRegMsg);
241                         pnfRegMsgConsumer.processMsg(pnfRegMsg_SSH);
242                         pnfRegMsgConsumer.processMsg(pnfRegMsg_TLS);
243                         pnfRegMsgConsumer.processMsg(pnfRegMsg_OTHER);          
244                 } catch (Exception e) {
245                         e.printStackTrace();
246                         System.out.println("Exception while processing PNF Registration Message - "+e.getMessage());
247                 }
248         }
249         
250         @Override
251         public PNFMountPointClient getPNFMountPointClient(String baseUrl) {
252                 return new TestPNFMountPointClient();
253         }
254         
255         @Override
256         public String getSDNRUser() {
257                 return DEFAULT_SDNRUSER;
258         }
259         
260         @Override
261         public String getSDNRPasswd() {
262                 return DEFAULT_SDNRPASSWD;
263         }
264         
265         @Override
266         public String getBaseUrl() {
267                 return DEFAULT_SDNRBASEURL;
268         }
269
270         @Test
271         public void Test1() {
272                 TestGeneralConfig cfgTest = new TestGeneralConfig();
273                 cfgTest.test();
274                 DMaaPPNFRegVESMsgConsumer pnfConsumer = new DMaaPPNFRegVESMsgConsumer();
275                 System.out.println(pnfConsumer.getBaseUrl());
276                 System.out.println(pnfConsumer.getSDNRUser());
277                 System.out.println(pnfConsumer.getSDNRPasswd());
278         }
279 }