ab907ead79996476aa615f6057146a146e6ea7b2
[ccsdk/features.git] /
1 /*
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.test;
19
20 import static org.mockito.Mockito.mock;
21 import static org.mockito.Mockito.when;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.OnfMicrowaveModel;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl.DeviceManagerOnfConfiguration;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Microwave;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
30 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
31 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
32 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
33 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
34 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
35 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
37 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
38 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
39
40 public class TestONFCoreNetworkElement12Microwave {
41
42     NetconfBindingAccessor accessor;
43     DeviceManagerServiceProvider serviceProvider;
44     Capabilities capabilities;
45     TransactionUtils transactionUtils;
46     NetworkElement optionalNe;
47     OnfMicrowaveModel onfMicrowaveModel;
48     FaultService faultService;
49     EquipmentService equipmentService;
50     DeviceManagerOnfConfiguration configuration;
51
52     protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID =
53             InstanceIdentifier.builder(NetworkElement.class).build();
54
55     @Before
56     public void init() {
57         accessor = mock(NetconfBindingAccessor.class);
58         serviceProvider = mock(DeviceManagerServiceProvider.class);
59         capabilities = mock(Capabilities.class);
60         transactionUtils = mock(TransactionUtils.class);
61         onfMicrowaveModel = mock(OnfMicrowaveModel.class);
62         faultService = mock(FaultService.class);
63         equipmentService = mock(EquipmentService.class);
64         configuration = mock(DeviceManagerOnfConfiguration.class);
65
66         when(accessor.getCapabilites()).thenReturn(capabilities);
67         when(serviceProvider.getFaultService()).thenReturn(faultService);
68         when(serviceProvider.getEquipmentService()).thenReturn(equipmentService);
69
70         NodeId nNodeId = new NodeId("nSky");
71         when(accessor.getNodeId()).thenReturn(nNodeId);
72         when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME)).thenReturn(true);
73         when(accessor.getTransactionUtils()).thenReturn(transactionUtils);
74     }
75
76     @Test
77     public void test() {
78         optionalNe = mock(NetworkElement.class);
79
80         when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
81                 NETWORKELEMENT_IID)).thenReturn(optionalNe);
82
83         ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
84                 new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration, onfMicrowaveModel);
85         onfCoreNetworkElement12MW.prepareCheck();
86
87         EventlogEntity eventlogEntity = mock(EventlogEntity.class);
88         when(eventlogEntity.getObjectId()).thenReturn("ABCD");
89         when(eventlogEntity.getAttributeName()).thenReturn("/network-element/extension[value-name=\"top-level-equipment\"]/value");
90
91         onfCoreNetworkElement12MW.notificationActor(eventlogEntity);
92
93     }
94
95
96     @Test
97     public void test1() {
98         when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
99                 NETWORKELEMENT_IID)).thenReturn(null);
100
101         ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
102                 new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration, onfMicrowaveModel);
103         onfCoreNetworkElement12MW.prepareCheck();
104
105         EventlogEntity eventlogEntity = mock(EventlogEntity.class);
106         when(eventlogEntity.getObjectId()).thenReturn("ABCD");
107         when(eventlogEntity.getAttributeName()).thenReturn("/equipment-pac/equipment-current-problems");
108
109         onfCoreNetworkElement12MW.notificationActor(eventlogEntity);
110     }
111
112
113 }