b536460a024e17020d7f87b64e62837bf2b8ab36
[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.devicemanager.oran.test;
19
20 import static org.mockito.Mockito.verify;
21 import static org.mockito.Mockito.when;
22 import org.junit.Test;
23 import org.junit.runner.RunWith;
24 import org.mockito.Mock;
25 import org.mockito.junit.MockitoJUnitRunner;
26 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanFaultNotificationListener;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
30 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType;
34 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
35
36 @RunWith(MockitoJUnitRunner.class)
37 public class TestORanFaultNotificationListener {
38
39     @Mock
40     NetconfBindingAccessor bindingAccessor;
41     @Mock
42     DataProvider dataProvider;
43     @Mock
44     VESCollectorService vesCollectorService;
45     @Mock
46     VESCollectorCfgService vesCfgService;
47
48     @Test
49     public void test() {
50         when(bindingAccessor.getNodeId()).thenReturn(new NodeId("nSky"));
51         when(vesCollectorService.getConfig()).thenReturn(vesCfgService);
52         when(vesCfgService.isVESCollectorEnabled()).thenReturn(true);
53
54         ORanFaultNotificationListener faultListener = new ORanFaultNotificationListener(bindingAccessor, dataProvider, vesCollectorService);
55         faultListener.onAlarmNotif(new TestAlarmNotif());
56         verify(dataProvider).updateFaultCurrent(new FaultcurrentBuilder().setCounter(0)
57                                                         .setNodeId("nSky")
58                                                         .setId("123")
59                                                         .setProblem("CPRI Port Down")
60                                                         .setSeverity(SeverityType.Critical)
61                                                         .setObjectId("ORAN-RU-FH")
62                                                         .setTimestamp(new DateAndTime("2021-03-23T18:19:42.326144Z"))
63                                                         .build());
64     }
65 }