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.ONFCoreNetworkElement12Microwave;
 
  30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
 
  31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService;
 
  32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
 
  33 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
 
  34 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
 
  35 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
 
  36 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 
  37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
 
  38 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeControl;
 
  39 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeState;
 
  40 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LifecycleState;
 
  41 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
 
  42 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.OperationalState;
 
  43 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
 
  44 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension;
 
  45 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.global._class.g.LocalId;
 
  46 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.label.g.Label;
 
  47 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.name.g.Name;
 
  48 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Fd;
 
  49 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Ltp;
 
  50 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac;
 
  51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
 
  52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
 
  53 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 
  54 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
  55 import org.opendaylight.yangtools.yang.binding.DataContainer;
 
  56 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
  58 public class TestONFCoreNetworkElement12Microwave {
 
  60     NetconfAccessor accessor;
 
  61     DeviceManagerServiceProvider serviceProvider;
 
  62     Capabilities capabilities;
 
  63     TransactionUtils transactionUtils;
 
  64     NetworkElement optionalNe;
 
  65     OnfMicrowaveModel onfMicrowaveModel;
 
  66     FaultService faultService;
 
  67     EquipmentService equipmentService;
 
  68     DeviceManagerOnfConfiguration configuration;
 
  70     protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier
 
  71             .builder(NetworkElement.class).build();
 
  75         accessor = mock(NetconfAccessor.class);
 
  76         serviceProvider = mock(DeviceManagerServiceProvider.class);
 
  77         capabilities = mock(Capabilities.class);
 
  78         transactionUtils = mock(TransactionUtils.class);
 
  79         onfMicrowaveModel = mock(OnfMicrowaveModel.class);
 
  80         faultService = mock(FaultService.class);
 
  81         equipmentService = mock(EquipmentService.class);
 
  82         configuration = mock(DeviceManagerOnfConfiguration.class);
 
  84         when(accessor.getCapabilites()).thenReturn(capabilities);
 
  85         when(serviceProvider.getFaultService()).thenReturn(faultService);
 
  86         when(serviceProvider.getEquipmentService()).thenReturn(equipmentService);
 
  88         NodeId nNodeId = new NodeId("nSky");
 
  89         when(accessor.getNodeId()).thenReturn(nNodeId);
 
  90         when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME)).thenReturn(true);
 
  91         when(accessor.getTransactionUtils()).thenReturn(transactionUtils);
 
  97         optionalNe = new NetworkElement() {
 
 100             public @Nullable List<Label> getLabel() {
 
 101                 // TODO Auto-generated method stub
 
 106             public @Nullable List<Extension> getExtension() {
 
 107                 // TODO Auto-generated method stub
 
 112             public @Nullable OperationalState getOperationalState() {
 
 113                 // TODO Auto-generated method stub
 
 118             public @Nullable LifecycleState getLifecycleState() {
 
 119                 // TODO Auto-generated method stub
 
 124             public @Nullable AdministrativeState getAdministrativeState() {
 
 125                 // TODO Auto-generated method stub
 
 130             public @Nullable AdministrativeControl getAdministrativeControl() {
 
 131                 // TODO Auto-generated method stub
 
 136             public @Nullable List<Name> getName() {
 
 137                 // TODO Auto-generated method stub
 
 142             public @Nullable UniversalId getUuid() {
 
 143                 // TODO Auto-generated method stub
 
 148             public @Nullable List<LocalId> getLocalId() {
 
 149                 // TODO Auto-generated method stub
 
 154             public <E$$ extends Augmentation<NetworkElement>> @Nullable E$$ augmentation(Class<E$$> augmentationType) {
 
 155                 // TODO Auto-generated method stub
 
 160             public Class<? extends DataContainer> getImplementedInterface() {
 
 161                 // TODO Auto-generated method stub
 
 166             public @Nullable List<Ltp> getLtp() {
 
 167                 // TODO Auto-generated method stub
 
 172             public @Nullable List<Fd> getFd() {
 
 173                 // TODO Auto-generated method stub
 
 178         when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
 
 179                 NETWORKELEMENT_IID)).thenReturn(optionalNe);
 
 181         ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW = new ONFCoreNetworkElement12Microwave(accessor,
 
 182                 serviceProvider, configuration, onfMicrowaveModel);
 
 183         onfCoreNetworkElement12MW.prepareCheck();
 
 185         EventlogEntity eventlogEntity = new EventlogEntity() {
 
 188             public @Nullable String getId() {
 
 189                 // TODO Auto-generated method stub
 
 194             public @Nullable DateAndTime getTimestamp() {
 
 195                 // TODO Auto-generated method stub
 
 200             public @Nullable String getObjectId() {
 
 201                 // TODO Auto-generated method stub
 
 206             public @Nullable String getNodeId() {
 
 207                 // TODO Auto-generated method stub
 
 212             public @Nullable Integer getCounter() {
 
 213                 // TODO Auto-generated method stub
 
 218             public @Nullable SourceType getSourceType() {
 
 219                 // TODO Auto-generated method stub
 
 224             public @Nullable String getNewValue() {
 
 225                 // TODO Auto-generated method stub
 
 230             public @Nullable String getAttributeName() {
 
 231                 // TODO Auto-generated method stub
 
 232                 return "/network-element/extension[value-name=\"top-level-equipment\"]/value"; // "/equipment-pac/equipment-current-problems";
 
 236             public Class<? extends DataContainer> getImplementedInterface() {
 
 237                 // TODO Auto-generated method stub
 
 242         onfCoreNetworkElement12MW.notificationActor(eventlogEntity);
 
 250         when (accessor.getTransactionUtils().readData(accessor.getDataBroker(),
 
 251                 LogicalDatastoreType.OPERATIONAL, NETWORKELEMENT_IID)).thenReturn(null);
 
 253         ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
 
 254                 new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration,
 
 255                         onfMicrowaveModel); onfCoreNetworkElement12MW.prepareCheck();
 
 257                         EventlogEntity eventlogEntity = new EventlogEntity() {
 
 260                             public @Nullable String getId() {
 
 261                                 // TODO Auto-generated method stub
 
 266                             public @Nullable DateAndTime getTimestamp() {
 
 267                                 // TODO Auto-generated method stub
 
 272                             public @Nullable String getObjectId() {
 
 273                                 // TODO Auto-generated method stub
 
 278                             public @Nullable String getNodeId() {
 
 279                                 // TODO Auto-generated method stub
 
 284                             public @Nullable Integer getCounter() {
 
 285                                 // TODO Auto-generated method stub
 
 290                             public @Nullable SourceType getSourceType() {
 
 291                                 // TODO Auto-generated method stub
 
 296                             public @Nullable String getNewValue() {
 
 297                                 // TODO Auto-generated method stub
 
 302                             public @Nullable String getAttributeName() {
 
 303                                 // TODO Auto-generated method stub
 
 304                                 return "/equipment-pac/equipment-current-problems";
 
 308                             public Class<? extends DataContainer> getImplementedInterface() {
 
 309                                 // TODO Auto-generated method stub
 
 314                         onfCoreNetworkElement12MW.notificationActor(eventlogEntity);