42f7de1d66ac523f48a24f7e4162347aef460cd3
[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.NetconfAccessor;
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
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     NetconfAccessor netconfAccessor;
52     Capabilities capabilities;
53     TransactionUtils transactionUtils;
54     DataBroker dataBroker;
55
56     @Before
57     public void init() {
58         netconfAccessor = mock(NetconfAccessor.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 = Arrays.asList(new PortDsListBuilder().setPortIdentity(portIdentity).build());
70         InstanceList instanceList = new InstanceListBuilder().setPortDsList(portDsList).build();
71         InstanceIdentifier<InstanceList> PTPINSTANCES_IID =
72                 InstanceIdentifier.builder(InstanceList.class, new InstanceListKey(1)).build();
73         when(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(),
74                 LogicalDatastoreType.OPERATIONAL, PTPINSTANCES_IID)).thenReturn(instanceList);
75     }
76
77     @Test
78     public void test() {
79
80         when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(false);
81
82         WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);
83     }
84
85     @Test
86     public void test1() {
87
88         when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(true);
89
90         WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);
91     }
92
93 }