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