a890b63d4c6a7afce80c23f1002691d9c703f28e
[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.junit.Assert.*;
21
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;
42
43 import java.util.Arrays;
44 import java.util.List;
45
46 import static org.mockito.Mockito.*;
47
48 public class TestWrapperPTPModelRev170208 {
49
50     private static final String NODEID = "node1";
51     NetconfBindingAccessor netconfAccessor;
52     Capabilities capabilities;
53     TransactionUtils transactionUtils;
54     DataBroker dataBroker;
55
56     @Before
57     public void init() {
58         netconfAccessor = mock(NetconfBindingAccessor.class);
59         capabilities = mock(Capabilities.class);
60         dataBroker = mock(DataBroker.class);
61         transactionUtils = mock(TransactionUtils.class);
62
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);
67
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);
77     }
78
79     @Test
80     public void test() {
81
82         when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(false);
83
84         WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);
85     }
86
87     @Test
88     public void test1() {
89
90         when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(true);
91
92         WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);
93     }
94
95 }