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;
22 import java.util.Optional;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.OnfMicrowaveModel;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl.DeviceManagerOnfConfiguration;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Microwave;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
31 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
32 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
33 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNotifications;
34 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
35 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
36 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
37 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
39 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
40 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
42 public class TestONFCoreNetworkElement12Microwave {
44 NetconfBindingAccessor accessor;
45 DeviceManagerServiceProvider serviceProvider;
46 Capabilities capabilities;
47 TransactionUtils transactionUtils;
48 NetworkElement optionalNe;
49 OnfMicrowaveModel onfMicrowaveModel;
50 FaultService faultService;
51 EquipmentService equipmentService;
52 DeviceManagerOnfConfiguration configuration;
54 protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID =
55 InstanceIdentifier.builder(NetworkElement.class).build();
59 accessor = mock(NetconfBindingAccessor.class);
60 serviceProvider = mock(DeviceManagerServiceProvider.class);
61 capabilities = mock(Capabilities.class);
62 transactionUtils = mock(TransactionUtils.class);
63 onfMicrowaveModel = mock(OnfMicrowaveModel.class);
64 faultService = mock(FaultService.class);
65 equipmentService = mock(EquipmentService.class);
66 configuration = mock(DeviceManagerOnfConfiguration.class);
68 when(accessor.getCapabilites()).thenReturn(capabilities);
69 when(serviceProvider.getFaultService()).thenReturn(faultService);
70 when(serviceProvider.getEquipmentService()).thenReturn(equipmentService);
72 NodeId nNodeId = new NodeId("nSky");
73 when(accessor.getNodeId()).thenReturn(nNodeId);
74 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME)).thenReturn(true);
75 when(accessor.getTransactionUtils()).thenReturn(transactionUtils);
76 when(accessor.getNotificationAccessor()).thenReturn(Optional.of(mock(NetconfNotifications.class)));
82 optionalNe = mock(NetworkElement.class);
84 when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
85 NETWORKELEMENT_IID)).thenReturn(optionalNe);
87 ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
88 new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration, onfMicrowaveModel);
89 onfCoreNetworkElement12MW.prepareCheck();
91 EventlogEntity eventlogEntity = mock(EventlogEntity.class);
92 when(eventlogEntity.getObjectId()).thenReturn("ABCD");
93 when(eventlogEntity.getAttributeName()).thenReturn("/network-element/extension[value-name=\"top-level-equipment\"]/value");
95 onfCoreNetworkElement12MW.notificationActor(eventlogEntity);
101 public void test1() {
102 when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
103 NETWORKELEMENT_IID)).thenReturn(null);
105 ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
106 new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration, onfMicrowaveModel);
107 onfCoreNetworkElement12MW.prepareCheck();
109 EventlogEntity eventlogEntity = mock(EventlogEntity.class);
110 when(eventlogEntity.getObjectId()).thenReturn("ABCD");
111 when(eventlogEntity.getAttributeName()).thenReturn("/equipment-pac/equipment-current-problems");
113 onfCoreNetworkElement12MW.notificationActor(eventlogEntity);