2adc248e167110eb2a6b9660458dde0644ceb3dc
[ccsdk/features.git] / sdnr / wt / devicemanager-onap / onf12 / provider / src / test / java / org / onap / ccsdk / features / sdnr / wt / devicemanager / onf / ifpac / test / TestWrapperPTPModelRev170208.java
1 /*
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.test;
19
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.opendaylight.mdsal.binding.api.DataBroker;
31 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceList;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceListBuilder;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceListKey;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.instance.list.PortDsList;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.instance.list.PortDsListBuilder;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.port.ds.entry.PortIdentity;
38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.port.ds.entry.PortIdentityBuilder;
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;
41 import org.opendaylight.yangtools.yang.common.Uint16;
42
43 public class TestWrapperPTPModelRev170208 {
44
45     private static final String NODEID = "node1";
46     NetconfBindingAccessor netconfAccessor;
47     Capabilities capabilities;
48     TransactionUtils transactionUtils;
49     DataBroker dataBroker;
50
51     @Before
52     public void init() {
53         netconfAccessor = mock(NetconfBindingAccessor.class);
54         capabilities = mock(Capabilities.class);
55         dataBroker = mock(DataBroker.class);
56         transactionUtils = mock(TransactionUtils.class);
57
58         when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID));
59         when(netconfAccessor.getCapabilites()).thenReturn(capabilities);
60         when(netconfAccessor.getTransactionUtils()).thenReturn(transactionUtils);
61         when(netconfAccessor.getDataBroker()).thenReturn(dataBroker);
62
63         Uint16 portNumber = Uint16.valueOf(10);
64         PortIdentity portIdentity = new PortIdentityBuilder().setPortNumber(portNumber).build();
65         List<PortDsList> portDsList =
66                 Arrays.asList(new PortDsListBuilder().setPortNumber(portNumber).setPortIdentity(portIdentity).build());
67         InstanceList instanceList =
68                 new InstanceListBuilder().setInstanceNumber(Uint16.valueOf(1)).setPortDsList(portDsList).build();
69         InstanceIdentifier<InstanceList> PTPINSTANCES_IID =
70                 InstanceIdentifier.builder(InstanceList.class, new InstanceListKey(1)).build();
71         when(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(),
72                 LogicalDatastoreType.OPERATIONAL, PTPINSTANCES_IID)).thenReturn(instanceList);
73     }
74
75     @Test
76     public void test() {
77
78         when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(false);
79
80         WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);
81     }
82
83     @Test
84     public void test1() {
85
86         when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(true);
87
88         WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);
89     }
90
91 }