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
 
  10  * http://www.apache.org/licenses/LICENSE-2.0
 
  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
 
  16  * ============LICENSE_END==========================================================================
 
  18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.equipment.test;
 
  20 import static org.junit.Assert.*;
 
  21 import static org.mockito.Mockito.mock;
 
  22 import static org.mockito.Mockito.when;
 
  24 import java.lang.reflect.Constructor;
 
  25 import java.lang.reflect.InvocationTargetException;
 
  26 import java.util.Arrays;
 
  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;
 
  46 public class TestONFCoreNetworkElement12Equipment {
 
  48         NetconfAccessor netconfAccessor;
 
  49         Capabilities capabilities;
 
  50         NetworkElementCoreData coreData;
 
  52         TransactionUtils transactionUtils;
 
  53         EquipmentCurrentProblems eqptCurrProblems;
 
  54         DataBroker dataBroker;
 
  55         UniversalId uid = new UniversalId("ID");
 
  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);
 
  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 = InstanceIdentifier
 
  73                 .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(), LogicalDatastoreType.OPERATIONAL, interfaceIID)).thenReturn(eqptCurrProblems);
 
  82                 when(capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)).thenReturn(true);
 
  83                 ONFCoreNetworkElement12Equipment onfCoreEqpt = new ONFCoreNetworkElement12Equipment(netconfAccessor, coreData, capabilities);
 
  84                 onfCoreEqpt.addProblemsofNode(faultData);
 
  85                 onfCoreEqpt.addProblemsofNodeObject("ABCD");
 
  86                 onfCoreEqpt.getInventoryInformation(Arrays.asList("TESTINV"));
 
  87                 onfCoreEqpt.getEquipmentAll();
 
  88                 onfCoreEqpt.getEquipmentData();
 
  89                 onfCoreEqpt.getEquipmentPac();
 
  90                 onfCoreEqpt.readNetworkElementEquipment();
 
  96                 when(capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)).thenReturn(false);
 
  97                 ONFCoreNetworkElement12Equipment onfCoreEqpt = new ONFCoreNetworkElement12Equipment(netconfAccessor, coreData, capabilities);