cf25e1e7b57b7705a2a5e24403d5b361e9487782
[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 java.io.IOException;
22 import org.junit.After;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPFaultVESMsgConsumer;
26
27 public class TestDMaaPFaultVESMsgConsumer {
28
29     private static final String DEFAULT_SDNRUSER = "admin";
30     private static final String DEFAULT_SDNRPASSWD = "admin";
31     private static final String DEFAULT_SDNRBASEURL = "http://localhost:8181";
32     private static final String CONFIGURATIONFILE = "test2.properties";
33
34     // @formatter:off
35     private static final String faultVESMsg = ""
36             + "{\"event\":" + " {\"commonEventHeader\":"
37             + "         {       \"domain\":\"fault\","
38             + "                 \"eventId\":\"1e9a28bcd119_50007_2019-11-20T14:59:47.3Z\","
39             + "                 \"eventName\":\"fault_O_RAN_COMPONENT_Alarms\","
40             + "                 \"eventType\":\"O_RAN_COMPONENT_Alarms\","
41             + "                 \"sequence\":1,"
42             + "                 \"priority\":\"Low\","
43             + "                 \"reportingEntityId\":\"\","
44             + "                 \"reportingEntityName\":\"1e9a28bcd119_50007\","
45             + "                 \"sourceId\":\"\","
46             + "                 \"sourceName\":\"1e9a28bcd119_50007\","
47             + "                 \"startEpochMicrosec\":1614004128699785,"
48             + "                 \"lastEpochMicrosec\":1614004128699785,"
49             + "                 \"nfNamingCode\":\"sdn controller\","
50             + "                 \"nfVendorName\":\"sdn\","
51             + "                 \"timeZoneOffset\":\"+00:00\","
52             + "                 \"version\":\"4.0.1\","
53             + "                 \"vesEventListenerVersion\":\"7.0.1\""
54             + "         },"
55             + "         \"faultFields\":"
56             + "         {"
57             + "                 \"faultFieldsVersion\":\"4.0\","
58             + "                 \"alarmCondition\":\"8\","
59             + "                 \"alarmInterfaceA\":\"dkom32\","
60             + "                 \"eventSourceType\":\"O_RAN_COMPONENT\","
61             + "                 \"specificProblem\":\"dsonj32 don32 mdson32pk654\","
62             + "                 \"eventSeverity\":\"@eventSeverity@\","
63             + "                 \"vfStatus\":\"Active\","
64             + "                 \"alarmAdditionalInformation\":"
65             + "                 {"
66             + "                         \"eventTime\":\"2019-11-20T14:59:47.3Z\","
67             + "                         \"equipType\":\"O-RAN-sim\","
68             + "                         \"vendor\":\"Melacon\","
69             + "                         \"model\":\"Simulated Device\""
70             + "                 }"
71             + "         }"
72             + " }"
73             + "}";
74     // @formatter:on
75     // @formatter:off
76     private static final String faultVESMsg_Incomplete = ""
77             + "{\"event\":"
78             + " {\"commonEventHeader\":"
79             + "         {       \"domain\":\"fault\","
80             + "                 \"eventId\":\"1e9a28bcd119_50007_2019-11-20T14:59:47.3Z\","
81             + "                 \"eventName\":\"fault_O_RAN_COMPONENT_Alarms\","
82             + "                 \"eventType\":\"O_RAN_COMPONENT_Alarms\","
83             + "                 \"sequence\":1,"
84             + "                 \"priority\":\"Low\","
85             + "                 \"reportingEntityId\":\"\","
86             + "                 \"reportingEntityName\":\"1e9a28bcd119_50007\","
87             + "                 \"sourceId\":\"\","
88             + "                 \"sourceName\":\"1e9a28bcd119_50007\","
89             + "                 \"startEpochMicrosec\":1612349525626,"
90             + "                 \"lastEpochMicrosec\":1612349525626,"
91             + "                 \"nfNamingCode\":\"sdn controller\","
92             + "                 \"nfVendorName\":\"sdn\","
93             + "                 \"timeZoneOffset\":\"+00:00\","
94             + "                 \"version\":\"4.0.1\","
95             + "                 \"vesEventListenerVersion\":\"7.0.1\","
96             + "         },"
97             + "         \"faultFields\":"
98             + "         {"
99             + "                 \"faultFieldsVersion\":\"4.0\","
100             + "                 \"alarmCondition\":\"8\","
101             + "                 \"alarmInterfaceA\":\"dkom32\","
102             + "                 \"eventSourceType\":\"O_RAN_COMPONENT\","
103             + "                 \"specificProblem\":\"dsonj32 don32 mdson32pk654\","
104             + "                 \"eventSeverity\":\"CRITICAL\","
105             + "                 \"vfStatus\":\"Active\","
106             + "                 \"alarmAdditionalInformation\":"
107             + "                 {"
108             + "                         \"eventTime\":\"2019-11-20T14:59:47.3Z\","
109             + "                         \"equipType\":\"O-RAN-sim\","
110             + "                         \"vendor\":\"Melacon\","
111             + "                         \"model\":\"Simulated Device\""
112             + "                 }"
113             + "         }"
114             + " }"
115             + "}";
116     // @formatter:on
117
118     private GeneralConfigForTest cfgTest;
119
120     @Before
121     public void before() throws IOException {
122         cfgTest = new GeneralConfigForTest(CONFIGURATIONFILE);
123     }
124     @After
125     public void after() {
126         cfgTest.close();
127     }
128
129
130     @Test
131     public void test() throws IOException {
132         DMaaPFaultVESMsgConsumer faultMsgConsumer = new DMaaPFaultVESMsgConsumer(cfgTest.getCfg());
133         try {
134
135             faultMsgConsumer.processMsg(faultVESMsg.replace("@eventSeverity@", "CRITICAL"));
136             faultMsgConsumer.processMsg(faultVESMsg.replace("@eventSeverity@", "Major"));
137             faultMsgConsumer.processMsg(faultVESMsg.replace("@eventSeverity@", "minor"));
138             faultMsgConsumer.processMsg(faultVESMsg.replace("@eventSeverity@", "NonAlarmed"));
139             faultMsgConsumer.processMsg(faultVESMsg.replace("@eventSeverity@", "warning"));
140             faultMsgConsumer.processMsg(faultVESMsg.replace("@eventSeverity@", "Unknown"));
141             faultMsgConsumer.processMsg(faultVESMsg_Incomplete);
142         } catch (Exception e) {
143             e.printStackTrace();
144             System.out.println("Exception while processing Fault Message - " + e.getMessage());
145         }
146     }
147
148 }