3770cea67885ae50af35b4ecbe1abda598417461
[ccsdk/features.git] /
1 /*******************************************************************************
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2020 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 package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup;
19
20 import static org.junit.Assert.assertNotNull;
21 import static org.junit.Assert.assertNull;
22
23 import org.json.JSONObject;
24 import org.junit.Test;
25 import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
26 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
27 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
28 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter;
29 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.elalto.ElAltoReleaseInformation;
30
31 /**
32  * @author Michael Dürre
33  *
34  */
35 public class TestElAltoToFrankfurtConversion {
36
37         private static final JSONObject FAULTLOG_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n"
38                         + "\"_type\": \"faultlog\",\n" + "\"_id\": \"sim12600/LP-MWS-TTP-01/unknownProblem1\",\n"
39                         + "\"_version\": 1,\n" + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"fault\": {\n"
40                         + "\"nodeName\": \"sim12600\",\n" + "\"counter\": \"1\",\n" + "\"timeStamp\": \"2017-01-01T00:00:00.0Z\",\n"
41                         + "\"objectId\": \"LP-MWS-TTP-01\",\n" + "\"problem\": \"unknownProblem1\",\n"
42                         + "\"severity\": \"Critical\",\n" + "\"type\": \"ProblemNotificationXml\"\n" + "}\n" + "}\n" + "}");
43         private static final JSONObject FAULTCURRENT_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n"
44                         + "\"_type\": \"faultcurrent\",\n" + "\"_id\": \"sim12600/LP-MWS-TTP-01/unknownProblem1\",\n"
45                         + "\"_version\": 1,\n" + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"faultCurrent\": {\n"
46                         + "\"nodeName\": \"sim12600\",\n" + "\"counter\": \"1\",\n" + "\"timeStamp\": \"2017-01-01T00:00:00.0Z\",\n"
47                         + "\"objectId\": \"LP-MWS-TTP-01\",\n" + "\"problem\": \"unknownProblem1\",\n"
48                         + "\"severity\": \"Critical\",\n" + "\"type\": \"ProblemNotificationXml\"\n" + "}\n" + "}\n" + "}");
49         private static final JSONObject INVENTORY_SEARCHHIT = new JSONObject(
50                         "{\n" + "\"_index\": \"sdnevents_v1\",\n" + "\"_type\": \"inventoryequipment\",\n"
51                                         + "\"_id\": \"sim12600/a2.module-1.1.5.5\",\n" + "\"_version\": 1,\n" + "\"_score\": 1,\n"
52                                         + "\"_source\": {\n" + "\"treeLevel\": 2,\n" + "\"parentUuid\": \"CARD-1.1.5.0\",\n"
53                                         + "\"mountpoint\": \"sim12600\",\n" + "\"uuid\": \"a2.module-1.1.5.5\",\n"
54                                         + "\"containedHolder\": [\n" + "\"SUBRACK-1.55.0.0\"\n" + "],\n" + "\"manufacturerName\": null,\n"
55                                         + "\"manufacturerIdentifier\": \"ONF-Wireless-Transport\",\n" + "\"serial\": \"310330015\",\n"
56                                         + "\"date\": \"2013-04-13T00:00:00.0Z\",\n" + "\"version\": \"a2.module-newest\",\n"
57                                         + "\"description\": \"WS/p8.module/a2.module#5\",\n" + "\"partTypeId\": \"3EM23141AD01\",\n"
58                                         + "\"modelIdentifier\": \"CRPQABVFAA\",\n" + "\"typeName\": \"a2.module\"\n" + "}\n" + "}");
59         private static final JSONObject REQUIREDNE_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"mwtn_v1\",\n"
60                         + "\"_type\": \"required-networkelement\",\n" + "\"_id\": \"sim2230\",\n" + "\"_version\": 1,\n"
61                         + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"mountId\": \"sim2230\",\n" + "\"host\": \"10.20.5.2\",\n"
62                         + "\"port\": 2230,\n" + "\"username\": \"adsa\",\n" + "\"password\": \"asda\"\n" + "}\n" + "}");
63         private static final JSONObject EVENTLOG_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n"
64                         + "\"_type\": \"eventlog\",\n" + "\"_id\": \"AXB7cJHlZ_FApnwi29xq\",\n" + "\"_version\": 1,\n"
65                         + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"event\": {\n"
66                         + "\"nodeName\": \"SDN-Controller-465e2ae306ca\",\n" + "\"counter\": \"1\",\n"
67                         + "\"timeStamp\": \"2020-02-25T08:22:19.8Z\",\n" + "\"objectId\": \"sim2230\",\n"
68                         + "\"attributeName\": \"ConnectionStatus\",\n" + "\"newValue\": \"connecting\",\n"
69                         + "\"type\": \"AttributeValueChangedNotificationXml\"\n" + "}\n" + "}\n" + "}");
70         private static final JSONObject MAINTENANCE_SEARCHHIT = new JSONObject("{\n" + 
71                         "\"_index\": \"mwtn_v1\",\n" + 
72                         "\"_type\": \"maintenancemode\",\n" + 
73                         "\"_id\": \"sim2230\",\n" + 
74                         "\"_version\": 1,\n" + 
75                         "\"_score\": 1,\n" + 
76                         "\"_source\": {\n" + 
77                         "\"node\": \"sim2230\",\n" + 
78                         "\"filter\": [\n" + 
79                         "{\n" + 
80                         "\"definition\": {\n" + 
81                         "\"object-id-ref\": \"\",\n" + 
82                         "\"problem\": \"\"\n" + 
83                         "},\n" + 
84                         "\"description\": \"\",\n" + 
85                         "\"start\": \"\",\n" + 
86                         "\"end\": \"\"\n" + 
87                         "}\n" + 
88                         "],\n" + 
89                         "\"active\": false\n" + 
90                         "}\n" + 
91                         "}");
92         @Test
93         public void test() {
94                 ElAltoReleaseInformation ri = new ElAltoReleaseInformation();
95                 //faultlog 
96                 SearchHitConverter faultlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.FAULTLOG);
97                 assertNotNull(faultlogConverter);
98                 SearchHit frankfurtFaultlogEntry = faultlogConverter.convert(new SearchHit(FAULTLOG_SEARCHHIT));
99                 assertNotNull(frankfurtFaultlogEntry);
100                 //faultcurrent
101                 SearchHitConverter faultcurrentConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.FAULTCURRENT);
102                 assertNotNull(faultcurrentConverter);
103                 SearchHit frankfurtFaultcurrentEntry = faultcurrentConverter.convert(new SearchHit(FAULTCURRENT_SEARCHHIT));
104                 assertNotNull(frankfurtFaultcurrentEntry);
105                 //inventory
106                 SearchHitConverter inventoryConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.INVENTORY);
107                 assertNotNull(inventoryConverter);
108                 SearchHit frankfurtInventory = inventoryConverter.convert(new SearchHit(INVENTORY_SEARCHHIT));
109                 assertNotNull(frankfurtInventory);
110                 //inventory
111                 SearchHitConverter neConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.REQUIRED_NETWORKELEMENT);
112                 assertNotNull(neConverter);
113                 SearchHit frankfurtNE = neConverter.convert(new SearchHit(REQUIREDNE_SEARCHHIT));
114                 assertNotNull(frankfurtNE);
115                 //eventlog
116                 SearchHitConverter eventlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.EVENTLOG);
117                 assertNotNull(eventlogConverter);
118                 SearchHit frankfurtEvent = eventlogConverter.convert(new SearchHit(EVENTLOG_SEARCHHIT));
119                 assertNull(frankfurtEvent);
120                 //eventlog->connectionlog
121                 SearchHitConverter conlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.CONNECTIONLOG);
122                 assertNotNull(conlogConverter);
123                 SearchHit frankfurtconlog = conlogConverter.convert(new SearchHit(EVENTLOG_SEARCHHIT));
124                 assertNotNull(frankfurtconlog);
125                 //maintenance
126                 SearchHitConverter maintenanceConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.MAINTENANCE);
127                 assertNotNull(maintenanceConverter);
128                 SearchHit frankfurtmaint = maintenanceConverter.convert(new SearchHit(MAINTENANCE_SEARCHHIT));
129                 assertNotNull(frankfurtmaint);
130
131         }
132
133 }