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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
16 * ============LICENSE_END==========================================================================
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom;
20 import java.time.Instant;
21 import org.eclipse.jdt.annotation.NonNull;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.mockito.Mockito;
25 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.Onf14DomWireInterfaceNotificationListener;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.util.NetconfDeviceNotification;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService;
32 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
33 import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService;
34 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
35 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
36 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
37 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
38 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
40 public class TestOnf14DomWireInterfaceNotificationListener extends Mockito {
41 private NetconfDomAccessor accessor;
42 private NodeId nodeId;
43 private DeviceManagerServiceProvider serviceProvider;
44 private FaultService faultService;
45 private DataProvider databaseService;
46 private NotificationService notificationService;
48 private @NonNull WebsocketManagerService websocketService;
52 accessor = mock(NetconfDomAccessor.class);
53 nodeId = mock(NodeId.class);
54 serviceProvider = mock(DeviceManagerServiceProvider.class);
55 faultService = mock(FaultService.class);
56 databaseService = mock(DataProvider.class);
57 notificationService = mock(NotificationService.class);
58 websocketService = mock(WebsocketManagerService.class);
60 when(accessor.getNodeId()).thenReturn(nodeId);
61 when(serviceProvider.getFaultService()).thenReturn(faultService);
62 when(serviceProvider.getDataProvider()).thenReturn(databaseService);
63 when(serviceProvider.getNotificationService()).thenReturn(notificationService);
64 when(serviceProvider.getWebsocketService()).thenReturn(websocketService);
68 public void testOtherNotif() {
69 Onf14DomWireInterfaceNotificationListener notifListener =
70 new Onf14DomWireInterfaceNotificationListener(accessor, serviceProvider);
72 NetconfDeviceNotification ndn =
73 new NetconfDeviceNotification(createWireInterfaceCreationNotification(), Instant.now());
74 notifListener.onNotification(ndn);
75 ndn = new NetconfDeviceNotification(createWireInterfaceAVCNotification(), Instant.now());
76 notifListener.onNotification(ndn);
77 ndn = new NetconfDeviceNotification(createWireInterfaceDeletionNotification(), Instant.now());
78 notifListener.onNotification(ndn);
79 ndn = new NetconfDeviceNotification(createWireInterfaceProblemNotification(), Instant.now());
80 notifListener.onNotification(ndn);
83 private ContainerNode createWireInterfaceProblemNotification() {
84 return Builders.containerBuilder()
86 NodeIdentifier.create(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION))
87 .withChild(ImmutableNodes
88 .leafNode(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER, "47"))
89 .withChild(ImmutableNodes.leafNode(
90 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_PROBLEM,
91 "12345678-0123-2345-abcd-0123456789AB"))
92 .withChild(ImmutableNodes.leafNode(
93 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF,
94 "12345678-0123-1234-abcd-0123456789AB"))
95 .withChild(ImmutableNodes.leafNode(
96 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP,
97 "2022-02-05T12:30:45.283Z"))
98 .withChild(ImmutableNodes.leafNode(
99 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_SEVERITY,
100 "SEVERITY_TYPE_CRITICAL"))
104 private ContainerNode createWireInterfaceAVCNotification() {
105 return Builders.containerBuilder()
107 NodeIdentifier.create(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION))
108 .withChild(ImmutableNodes
109 .leafNode(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_COUNTER, "47"))
110 .withChild(ImmutableNodes.leafNode(
111 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_ATTRIBUTE_NAME,
112 "12345678-0123-2345-abcd-0123456789AB"))
113 .withChild(ImmutableNodes.leafNode(
114 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_NEW_VALUE, "new-value"))
115 .withChild(ImmutableNodes.leafNode(
116 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_OBJECT_ID_REF,
117 "12345678-0123-1234-abcd-0123456789AB"))
118 .withChild(ImmutableNodes.leafNode(
119 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_TIMESTAMP,
120 "2022-02-05T12:30:45.283Z"))
124 private ContainerNode createWireInterfaceDeletionNotification() {
125 return Builders.containerBuilder()
127 NodeIdentifier.create(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION))
128 .withChild(ImmutableNodes
129 .leafNode(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_COUNTER, "47"))
130 .withChild(ImmutableNodes.leafNode(
131 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_TIMESTAMP,
132 "2022-02-05T12:30:45.283Z"))
133 .withChild(ImmutableNodes.leafNode(
134 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_OBJECT_ID_REF,
135 "12345678-0123-1234-abcd-0123456789AB"))
139 private ContainerNode createWireInterfaceCreationNotification() {
140 return Builders.containerBuilder()
142 NodeIdentifier.create(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION))
143 .withChild(ImmutableNodes
144 .leafNode(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION_COUNTER, "47"))
145 .withChild(ImmutableNodes.leafNode(
146 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION_OBJECT_TYPE,
147 "Wire-interface-name"))
148 .withChild(ImmutableNodes.leafNode(
149 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION_TIMESTAMP,
150 "2022-02-05T12:30:45.283Z"))
151 .withChild(ImmutableNodes.leafNode(
152 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION_OBJECT_ID_REF,
153 "12345678-0123-1234-abcd-0123456789AB"))