a35e756a64a1ad36a5ef9e69915b786ac8e9ade4
[ccsdk/features.git] /
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.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;
43
44 public class TestWrapperPTPModelRev170208 {
45
46     private static final String NODEID = "node1";
47     NetconfBindingAccessor netconfAccessor;
48     Capabilities capabilities;
49     TransactionUtils transactionUtils;
50     DataBroker dataBroker;
51
52     @Before
53     public void init() {
54         netconfAccessor = mock(NetconfBindingAccessor.class);
55         capabilities = mock(Capabilities.class);
56         dataBroker = mock(DataBroker.class);
57         transactionUtils = mock(TransactionUtils.class);
58
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);
63
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);
74     }
75
76     @Test
77     public void test() {
78
79         when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(false);
80
81         WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);
82     }
83
84     @Test
85     public void test1() {
86
87         when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(true);
88
89         WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);
90     }
91
92 }