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.onf.ifpac.test;
20 import static org.mockito.Mockito.mock;
21 import static org.mockito.Mockito.when;
22 import java.util.Arrays;
23 import java.util.List;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.WrapperPTPModelRev170208;
27 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
28 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
29 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
30 import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper;
31 import org.opendaylight.mdsal.binding.api.DataBroker;
32 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceList;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceListBuilder;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceListKey;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.instance.list.PortDsList;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.instance.list.PortDsListBuilder;
38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.port.ds.entry.PortIdentity;
39 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.port.ds.entry.PortIdentityBuilder;
40 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
41 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
42 import org.opendaylight.yangtools.yang.common.Uint16;
44 public class TestWrapperPTPModelRev170208 {
46 private static final String NODEID = "node1";
47 NetconfBindingAccessor netconfAccessor;
48 Capabilities capabilities;
49 TransactionUtils transactionUtils;
50 DataBroker dataBroker;
54 netconfAccessor = mock(NetconfBindingAccessor.class);
55 capabilities = mock(Capabilities.class);
56 dataBroker = mock(DataBroker.class);
57 transactionUtils = mock(TransactionUtils.class);
59 when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID));
60 when(netconfAccessor.getCapabilites()).thenReturn(capabilities);
61 when(netconfAccessor.getTransactionUtils()).thenReturn(transactionUtils);
62 when(netconfAccessor.getDataBroker()).thenReturn(dataBroker);
64 Uint16 portNumber = Uint16.valueOf(10);
65 PortIdentity portIdentity = new PortIdentityBuilder().setPortNumber(portNumber).build();
66 List<PortDsList> portDsList =
67 Arrays.asList(new PortDsListBuilder().setPortNumber(portNumber).setPortIdentity(portIdentity).build());
68 InstanceList instanceList =
69 new InstanceListBuilder().setInstanceNumber(Uint16.valueOf(1)).setPortDsList(YangToolsMapperHelper.toMap(portDsList)).build();
70 InstanceIdentifier<InstanceList> PTPINSTANCES_IID =
71 InstanceIdentifier.builder(InstanceList.class, new InstanceListKey(Uint16.valueOf(1))).build();
72 when(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(),
73 LogicalDatastoreType.OPERATIONAL, PTPINSTANCES_IID)).thenReturn(instanceList);
79 when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(false);
81 WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);
87 when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(true);
89 WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);