25fba92814b068e069fd8a3e71cea7f91f6f20e1
[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 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.TransactionUtils;
34 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
35 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
36 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
38 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
39 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
40
41 public class TestONFCoreNetworkElement12Basic {
42
43     NetconfBindingAccessor accessor;
44     DeviceManagerServiceProvider serviceProvider;
45     Capabilities capabilities;
46     TransactionUtils transactionUtils;
47     NetworkElement optionalNe;
48     OnfMicrowaveModel onfMicrowaveModel;
49     FaultService faultService;
50     EquipmentService equipmentService;
51     DeviceManagerOnfConfiguration configuration;
52
53     protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID =
54             InstanceIdentifier.builder(NetworkElement.class).build();
55
56     @Before
57     public void init() {
58         accessor = mock(NetconfBindingAccessor.class);
59         serviceProvider = mock(DeviceManagerServiceProvider.class);
60         capabilities = mock(Capabilities.class);
61         transactionUtils = mock(TransactionUtils.class);
62         onfMicrowaveModel = mock(OnfMicrowaveModel.class);
63         faultService = mock(FaultService.class);
64         equipmentService = mock(EquipmentService.class);
65         configuration = mock(DeviceManagerOnfConfiguration.class);
66
67         when(accessor.getCapabilites()).thenReturn(capabilities);
68         when(serviceProvider.getFaultService()).thenReturn(faultService);
69         when(serviceProvider.getEquipmentService()).thenReturn(equipmentService);
70
71         NodeId nNodeId = new NodeId("nSky");
72         when(accessor.getNodeId()).thenReturn(nNodeId);
73         when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME)).thenReturn(true);
74         when(accessor.getTransactionUtils()).thenReturn(transactionUtils);
75         NetconfBindingAccessor bindingAccessor = mock(NetconfBindingAccessor.class);
76         when(bindingAccessor.getNodeId()).thenReturn(nNodeId);
77         when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(bindingAccessor));
78
79     }
80
81     @Test
82     public void test1() {
83         when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
84                 NETWORKELEMENT_IID)).thenReturn(null);
85
86         ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
87                 new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration, onfMicrowaveModel);
88         onfCoreNetworkElement12MW.prepareCheck();
89
90         EventlogEntity eventlogEntity = mock(EventlogEntity.class);
91         when(eventlogEntity.getObjectId()).thenReturn("ABCD");
92         when(eventlogEntity.getAttributeName()).thenReturn("/equipment-pac/equipment-current-problems");
93
94         onfCoreNetworkElement12MW.notificationActor(eventlogEntity);
95     }
96
97
98 }