4034517999f965a13b78ea000a5ca5e36f8f1a70
[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.equipment.test;
19
20 import static org.junit.Assert.*;
21 import static org.mockito.Mockito.mock;
22 import static org.mockito.Mockito.when;
23
24 import java.lang.reflect.Constructor;
25 import java.lang.reflect.InvocationTargetException;
26 import java.util.Arrays;
27
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.NetworkElementCoreData;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.equipment.ONFCoreNetworkElement12Equipment;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.equipment.WrapperEquipmentPacRev170402;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
34 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
35 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
36 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
37 import org.opendaylight.mdsal.binding.api.DataBroker;
38 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
39 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
40 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.EquipmentPac;
41 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.EquipmentPacKey;
42 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.equipment.pac.EquipmentCurrentProblems;
43 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
44 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
45
46 public class TestONFCoreNetworkElement12Equipment {
47
48     NetconfAccessor netconfAccessor;
49     Capabilities capabilities;
50     NetworkElementCoreData coreData;
51     FaultData faultData;
52     TransactionUtils transactionUtils;
53     EquipmentCurrentProblems eqptCurrProblems;
54     DataBroker dataBroker;
55     UniversalId uid = new UniversalId("ID");
56
57
58     @Before
59     public void init() throws Exception {
60         netconfAccessor = mock(NetconfAccessor.class);
61         capabilities = mock(Capabilities.class);
62         coreData = mock(NetworkElementCoreData.class);
63         faultData = mock(FaultData.class);
64         eqptCurrProblems = mock(EquipmentCurrentProblems.class);
65         dataBroker = mock(DataBroker.class);
66         transactionUtils = mock(TransactionUtils.class);
67
68         final Class<EquipmentPac> clazzPac = EquipmentPac.class;
69         final Class<EquipmentPacKey> clazzPacKey = EquipmentPacKey.class;
70         final Class<EquipmentCurrentProblems> clazzProblems = EquipmentCurrentProblems.class;
71         Constructor<EquipmentPacKey> cons = clazzPacKey.getConstructor(UniversalId.class);
72         InstanceIdentifier<EquipmentCurrentProblems> interfaceIID =
73                 InstanceIdentifier.builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build();
74         when(netconfAccessor.getCapabilites()).thenReturn(capabilities);
75         when(netconfAccessor.getTransactionUtils()).thenReturn(transactionUtils);
76         when(netconfAccessor.getDataBroker()).thenReturn(dataBroker);
77         when(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(),
78                 LogicalDatastoreType.OPERATIONAL, interfaceIID)).thenReturn(eqptCurrProblems);
79     }
80
81     @Test
82     public void test() {
83         when(capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)).thenReturn(true);
84         ONFCoreNetworkElement12Equipment onfCoreEqpt =
85                 new ONFCoreNetworkElement12Equipment(netconfAccessor, coreData, capabilities);
86         onfCoreEqpt.addProblemsofNode(faultData);
87         onfCoreEqpt.addProblemsofNodeObject("ABCD");
88         onfCoreEqpt.getInventoryInformation(Arrays.asList("TESTINV"));
89         onfCoreEqpt.getEquipmentAll();
90         onfCoreEqpt.getEquipmentData();
91         onfCoreEqpt.getEquipmentPac();
92         onfCoreEqpt.readNetworkElementEquipment();
93
94     }
95
96     @Test
97     public void test1() {
98         when(capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)).thenReturn(false);
99         ONFCoreNetworkElement12Equipment onfCoreEqpt =
100                 new ONFCoreNetworkElement12Equipment(netconfAccessor, coreData, capabilities);
101     }
102
103 }