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.rev201110.EventlogEntity;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.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 =
71 InstanceIdentifier.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 = mock(NetworkElement.class);
99 when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
100 NETWORKELEMENT_IID)).thenReturn(optionalNe);
102 ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
103 new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration, onfMicrowaveModel);
104 onfCoreNetworkElement12MW.prepareCheck();
106 EventlogEntity eventlogEntity = mock(EventlogEntity.class);
107 when(eventlogEntity.getObjectId()).thenReturn("ABCD");
108 when(eventlogEntity.getAttributeName()).thenReturn("/network-element/extension[value-name=\"top-level-equipment\"]/value");
110 onfCoreNetworkElement12MW.notificationActor(eventlogEntity);
116 public void test1() {
117 when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
118 NETWORKELEMENT_IID)).thenReturn(null);
120 ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
121 new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration, onfMicrowaveModel);
122 onfCoreNetworkElement12MW.prepareCheck();
124 EventlogEntity eventlogEntity = mock(EventlogEntity.class);
125 when(eventlogEntity.getObjectId()).thenReturn("ABCD");
126 when(eventlogEntity.getAttributeName()).thenReturn("/equipment-pac/equipment-current-problems");
128 onfCoreNetworkElement12MW.notificationActor(eventlogEntity);