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==========================================================================
19 package org.onap.ccsdk.features.sdnr.wt.devicemanager.xran;
21 import static org.mockito.Mockito.*;
23 import java.util.Arrays;
24 import java.util.List;
26 import org.eclipse.jdt.annotation.NonNull;
27 import org.junit.Test;
28 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
29 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.EditBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
36 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
37 import org.opendaylight.yangtools.yang.binding.DataObject;
38 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
39 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
40 import org.oransc.oam.features.devicemanager.xran.impl.XRanChangeNotificationListener;
42 public class TestXRanChangeNotificationListener {
44 private static final String NODEID = "node1";
49 NetconfAccessor netconfAccessor = mock(NetconfAccessor.class);
50 DataProvider databaseService = mock(DataProvider.class);
51 XRanChangeNotificationListener notifListener = new XRanChangeNotificationListener(netconfAccessor,
53 when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID));
54 Iterable<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() {
57 public int compareTo(PathArgument arg0) {
62 public Class<? extends DataObject> getType() {
63 return DataObject.class;
66 InstanceIdentifier<?> target = InstanceIdentifier.create(pathArguments);
68 notifListener.onNetconfConfigChange(createNotification(EditOperationType.Create,target));
69 EventlogEntity event = new EventlogBuilder().setNodeId(NODEID)
70 .setNewValue(String.valueOf(EditOperationType.Create)).setObjectId(target.toString()).build();
71 verify(databaseService).writeEventLog(event);
79 private static NetconfConfigChange createNotification(EditOperationType type,InstanceIdentifier<?> target) {
80 NetconfConfigChange change = mock(NetconfConfigChange.class);
82 @SuppressWarnings("null")
83 final @NonNull List<Edit> edits = Arrays.asList(new EditBuilder().setOperation(type).setTarget(target).build());
84 when(change.nonnullEdit()).thenReturn(edits);