2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.test;
24 import static org.junit.Assert.assertEquals;
25 import static org.mockito.Mockito.mock;
26 import static org.mockito.Mockito.when;
27 import java.io.IOException;
28 import org.eclipse.jdt.annotation.NonNull;
29 import org.junit.BeforeClass;
30 import org.junit.Test;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl.OpenroadmFaultNotificationListener;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
34 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.AlarmNotification;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.Severity;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.alarm.ProbableCause;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.alarm.ProbableCauseBuilder;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.alarm.Resource;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.alarm.ResourceBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev191129.NodeIdType;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.probablecause.rev191129.ProbableCauseEnum;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.Device;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.DeviceBuilder;
45 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
47 public class TestOpenRoadmAlarmNotification {
48 private static final String myCircuitId = "Test_Id";
49 private static final String myId = "Alarm_Id";
50 DateAndTime myRaiseTime = new DateAndTime("2020-02-25T10:08:06.7Z");
51 ProbableCause myProbableCause =
52 new ProbableCauseBuilder().setCause(ProbableCauseEnum.AutomaticLaserShutdown).build();
53 Device device = new DeviceBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).build();
54 Resource myResource = new ResourceBuilder().setDevice(device).build();
55 static DeviceManagerServiceProvider serviceProvider;
56 static @NonNull FaultService faultService;
57 static AlarmNotification notification;
59 static NetconfAccessor accessor;
62 public static void init() throws InterruptedException, IOException {
64 accessor = mock(NetconfAccessor.class);
65 serviceProvider = mock(DeviceManagerServiceProvider.class);
66 faultService = mock(FaultService.class);
72 System.out.println("Shabnam");
76 public void testNotification() {
77 severity = Severity.Critical;
78 when(serviceProvider.getFaultService()).thenReturn(faultService);
79 OpenroadmFaultNotificationListener alarmListener =
80 new OpenroadmFaultNotificationListener(accessor, serviceProvider);
81 notification = mock(AlarmNotification.class);
83 when(notification.getId()).thenReturn(myId);
84 when(notification.getCircuitId()).thenReturn(myCircuitId);
85 when(notification.getRaiseTime()).thenReturn(myRaiseTime);
86 when(notification.getProbableCause()).thenReturn(myProbableCause);
87 when(notification.getResource()).thenReturn(myResource);
88 when(notification.getSeverity()).thenReturn(severity);
89 alarmListener.onAlarmNotification(notification);
90 System.out.println(notification.getId());
91 assertEquals(notification.getId(), myId);
92 assertEquals(notification.getCircuitId(), myCircuitId);
93 assertEquals(notification.getRaiseTime(), myRaiseTime);
94 assertEquals(notification.getProbableCause(), myProbableCause);
95 assertEquals(notification.getResource(), myResource);
96 assertEquals(notification.getSeverity(), severity);