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.mockito.Mockito.doReturn;
25 import static org.mockito.Mockito.mock;
26 import static org.mockito.Mockito.when;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl.OpenroadmDeviceChangeNotificationListener;
31 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev191129.RpcStatus;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.ChangeNotification;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.CreateTechInfoNotification;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OrgOpenroadmDevice;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.change.notification.Edit;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType;
38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
39 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
40 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
42 public class TestOpenRoadmDeviceChangeNotification {
44 private NetconfAccessor accessor = mock(NetconfAccessor.class);
45 private DataProvider databaseProvider = mock(DataProvider.class);
46 static ChangeNotification notification = mock(ChangeNotification.class);
47 static CreateTechInfoNotification notificationTechInfo = mock(CreateTechInfoNotification.class);
48 final EditOperationType operation = EditOperationType.Merge;
49 private NodeId nodeId = new NodeId("RoadmA2");
50 Edit change = mock(Edit.class);
51 final Class<OrgOpenroadmDevice> clazzRoadm = OrgOpenroadmDevice.class;
52 OpenroadmDeviceChangeNotificationListener changeListener =
53 new OpenroadmDeviceChangeNotificationListener(accessor, databaseProvider);
54 InstanceIdentifier<?> target = InstanceIdentifier.builder(clazzRoadm).build();
58 doReturn(target).when(change).getTarget();
59 when(change.getOperation()).thenReturn(operation);
60 when(accessor.getNodeId()).thenReturn(nodeId);
64 public void testOnChangeNotification() {
65 when(notification.getChangeTime()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z"));
66 changeListener.onChangeNotification(notification);
70 public void testCreateTechInfoNotification() {
71 when(notificationTechInfo.getShelfId()).thenReturn("Shelf688");
72 when(notificationTechInfo.getStatus()).thenReturn(RpcStatus.Successful);
73 changeListener.onCreateTechInfoNotification(notificationTechInfo);