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.ne.test;
 
  20 import static org.mockito.Mockito.mock;
 
  21 import static org.mockito.Mockito.when;
 
  23 import java.util.List;
 
  24 import org.eclipse.jdt.annotation.Nullable;
 
  25 import org.junit.Before;
 
  26 import org.junit.Test;
 
  27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.OnfMicrowaveModel;
 
  28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl.DeviceManagerOnfConfiguration;
 
  29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Basic;
 
  30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Microwave;
 
  31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
 
  32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService;
 
  33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
 
  34 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
 
  35 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
 
  36 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
 
  37 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 
  38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
 
  39 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeControl;
 
  40 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeState;
 
  41 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LifecycleState;
 
  42 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
 
  43 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.OperationalState;
 
  44 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
 
  45 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension;
 
  46 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.global._class.g.LocalId;
 
  47 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.label.g.Label;
 
  48 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.name.g.Name;
 
  49 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Fd;
 
  50 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Ltp;
 
  51 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac;
 
  52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
 
  53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
 
  54 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 
  55 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
  56 import org.opendaylight.yangtools.yang.binding.DataContainer;
 
  57 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
  59 public class TestONFCoreNetworkElement12Basic {
 
  61     NetconfAccessor accessor;
 
  62     DeviceManagerServiceProvider serviceProvider;
 
  63     Capabilities capabilities;
 
  64     TransactionUtils transactionUtils;
 
  65     NetworkElement optionalNe;
 
  66     OnfMicrowaveModel onfMicrowaveModel;
 
  67     FaultService faultService;
 
  68     EquipmentService equipmentService;
 
  69     DeviceManagerOnfConfiguration configuration;
 
  71     protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier
 
  72             .builder(NetworkElement.class).build();
 
  76         accessor = mock(NetconfAccessor.class);
 
  77         serviceProvider = mock(DeviceManagerServiceProvider.class);
 
  78         capabilities = mock(Capabilities.class);
 
  79         transactionUtils = mock(TransactionUtils.class);
 
  80         onfMicrowaveModel = mock(OnfMicrowaveModel.class);
 
  81         faultService = mock(FaultService.class);
 
  82         equipmentService = mock(EquipmentService.class);
 
  83         configuration = mock(DeviceManagerOnfConfiguration.class);
 
  85         when(accessor.getCapabilites()).thenReturn(capabilities);
 
  86         when(serviceProvider.getFaultService()).thenReturn(faultService);
 
  87         when(serviceProvider.getEquipmentService()).thenReturn(equipmentService);
 
  89         NodeId nNodeId = new NodeId("nSky");
 
  90         when(accessor.getNodeId()).thenReturn(nNodeId);
 
  91         when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME)).thenReturn(true);
 
  92         when(accessor.getTransactionUtils()).thenReturn(transactionUtils);
 
  98         optionalNe = new NetworkElement() {
 
 101             public @Nullable List<Label> getLabel() {
 
 102                 // TODO Auto-generated method stub
 
 107             public @Nullable List<Extension> getExtension() {
 
 108                 // TODO Auto-generated method stub
 
 113             public @Nullable OperationalState getOperationalState() {
 
 114                 // TODO Auto-generated method stub
 
 119             public @Nullable LifecycleState getLifecycleState() {
 
 120                 // TODO Auto-generated method stub
 
 125             public @Nullable AdministrativeState getAdministrativeState() {
 
 126                 // TODO Auto-generated method stub
 
 131             public @Nullable AdministrativeControl getAdministrativeControl() {
 
 132                 // TODO Auto-generated method stub
 
 137             public @Nullable List<Name> getName() {
 
 138                 // TODO Auto-generated method stub
 
 143             public @Nullable UniversalId getUuid() {
 
 144                 // TODO Auto-generated method stub
 
 149             public @Nullable List<LocalId> getLocalId() {
 
 150                 // TODO Auto-generated method stub
 
 155             public <E$$ extends Augmentation<NetworkElement>> @Nullable E$$ augmentation(Class<E$$> augmentationType) {
 
 156                 // TODO Auto-generated method stub
 
 161             public Class<? extends DataContainer> getImplementedInterface() {
 
 162                 // TODO Auto-generated method stub
 
 167             public @Nullable List<Ltp> getLtp() {
 
 168                 // TODO Auto-generated method stub
 
 173             public @Nullable List<Fd> getFd() {
 
 174                 // TODO Auto-generated method stub
 
 179         when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
 
 180                 NETWORKELEMENT_IID)).thenReturn(optionalNe);
 
 182         ONFCoreNetworkElement12Basic onfCoreNetworkElement12Basic = new ONFCoreNetworkElement12Basic(accessor,
 
 183                 serviceProvider,configuration);
 
 184         onfCoreNetworkElement12Basic.prepareCheck();
 
 187          * EventlogEntity eventlogEntity = new EventlogEntity() {
 
 189          * @Override public @Nullable String getId() { // TODO Auto-generated method
 
 190          * stub return null; }
 
 192          * @Override public @Nullable DateAndTime getTimestamp() { // TODO
 
 193          * Auto-generated method stub return null; }
 
 195          * @Override public @Nullable String getObjectId() { // TODO Auto-generated
 
 196          * method stub return "ABCD"; }
 
 198          * @Override public @Nullable String getNodeId() { // TODO Auto-generated method
 
 199          * stub return null; }
 
 201          * @Override public @Nullable Integer getCounter() { // TODO Auto-generated
 
 202          * method stub return null; }
 
 204          * @Override public @Nullable SourceType getSourceType() { // TODO
 
 205          * Auto-generated method stub return null; }
 
 207          * @Override public @Nullable String getNewValue() { // TODO Auto-generated
 
 208          * method stub return null; }
 
 210          * @Override public @Nullable String getAttributeName() { // TODO Auto-generated
 
 212          * "/network-element/extension[value-name=\"top-level-equipment\"]/value"; //
 
 213          * "/equipment-pac/equipment-current-problems"; }
 
 215          * @Override public Class<? extends DataContainer> getImplementedInterface() {
 
 216          * // TODO Auto-generated method stub return null; } };
 
 218          * onfCoreNetworkElement12Basic.notificationActor(eventlogEntity);
 
 227         when (accessor.getTransactionUtils().readData(accessor.getDataBroker(),
 
 228                 LogicalDatastoreType.OPERATIONAL, NETWORKELEMENT_IID)).thenReturn(null);
 
 230         ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
 
 231                 new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration,
 
 232                         onfMicrowaveModel); onfCoreNetworkElement12MW.prepareCheck();
 
 234                         EventlogEntity eventlogEntity = new EventlogEntity() {
 
 237                             public @Nullable String getId() {
 
 238                                 // TODO Auto-generated method stub
 
 243                             public @Nullable DateAndTime getTimestamp() {
 
 244                                 // TODO Auto-generated method stub
 
 249                             public @Nullable String getObjectId() {
 
 250                                 // TODO Auto-generated method stub
 
 255                             public @Nullable String getNodeId() {
 
 256                                 // TODO Auto-generated method stub
 
 261                             public @Nullable Integer getCounter() {
 
 262                                 // TODO Auto-generated method stub
 
 267                             public @Nullable SourceType getSourceType() {
 
 268                                 // TODO Auto-generated method stub
 
 273                             public @Nullable String getNewValue() {
 
 274                                 // TODO Auto-generated method stub
 
 279                             public @Nullable String getAttributeName() {
 
 280                                 // TODO Auto-generated method stub
 
 281                                 return "/equipment-pac/equipment-current-problems";
 
 285                             public Class<? extends DataContainer> getImplementedInterface() {
 
 286                                 // TODO Auto-generated method stub
 
 291                         onfCoreNetworkElement12MW.notificationActor(eventlogEntity);