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
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==========================================================================
17 ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.test;
20 import static org.junit.Assert.*;
21 import static org.mockito.Mockito.mock;
22 import static org.mockito.Mockito.when;
24 import java.util.List;
25 import java.util.Optional;
27 import org.eclipse.jdt.annotation.Nullable;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.OnfMicrowaveModel;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Basic;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Microwave;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
36 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
37 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
38 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
39 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
40 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
41 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeControl;
42 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeState;
43 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LifecycleState;
44 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
45 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.OperationalState;
46 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
47 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension;
48 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.global._class.g.LocalId;
49 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.label.g.Label;
50 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.name.g.Name;
51 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Fd;
52 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Ltp;
53 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
56 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
57 import org.opendaylight.yangtools.yang.binding.Augmentation;
58 import org.opendaylight.yangtools.yang.binding.DataContainer;
59 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
61 public class TestONFCoreNetworkElement12Microwave {
63 NetconfAccessor accessor;
64 DeviceManagerServiceProvider serviceProvider;
65 Capabilities capabilities;
66 TransactionUtils transactionUtils;
67 NetworkElement optionalNe;
68 OnfMicrowaveModel onfMicrowaveModel;
69 FaultService faultService;
70 EquipmentService equipmentService;
72 protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier
73 .builder(NetworkElement.class).build();
77 accessor = mock(NetconfAccessor.class);
78 serviceProvider = mock(DeviceManagerServiceProvider.class);
79 capabilities = mock(Capabilities.class);
80 transactionUtils = mock(TransactionUtils.class);
81 onfMicrowaveModel = mock(OnfMicrowaveModel.class);
82 faultService = mock(FaultService.class);
83 equipmentService = mock(EquipmentService.class);
85 when(accessor.getCapabilites()).thenReturn(capabilities);
86 when(serviceProvider.getFaultService()).thenReturn(faultService);
87 when(serviceProvider.getEquipmentService()).thenReturn(equipmentService);
89 NodeId nNodeId = new NodeId("nSky");
90 when(accessor.getNodeId()).thenReturn(nNodeId);
91 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME)).thenReturn(true);
92 when(accessor.getTransactionUtils()).thenReturn(transactionUtils);
98 optionalNe = new NetworkElement() {
101 public @Nullable List<Label> getLabel() {
102 // TODO Auto-generated method stub
107 public @Nullable List<Extension> getExtension() {
108 // TODO Auto-generated method stub
113 public @Nullable OperationalState getOperationalState() {
114 // TODO Auto-generated method stub
119 public @Nullable LifecycleState getLifecycleState() {
120 // TODO Auto-generated method stub
125 public @Nullable AdministrativeState getAdministrativeState() {
126 // TODO Auto-generated method stub
131 public @Nullable AdministrativeControl getAdministrativeControl() {
132 // TODO Auto-generated method stub
137 public @Nullable List<Name> getName() {
138 // TODO Auto-generated method stub
143 public @Nullable UniversalId getUuid() {
144 // TODO Auto-generated method stub
149 public @Nullable List<LocalId> getLocalId() {
150 // TODO Auto-generated method stub
155 public <E$$ extends Augmentation<NetworkElement>> @Nullable E$$ augmentation(Class<E$$> augmentationType) {
156 // TODO Auto-generated method stub
161 public Class<? extends DataContainer> getImplementedInterface() {
162 // TODO Auto-generated method stub
167 public @Nullable List<Ltp> getLtp() {
168 // TODO Auto-generated method stub
173 public @Nullable List<Fd> getFd() {
174 // TODO Auto-generated method stub
179 when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
180 NETWORKELEMENT_IID)).thenReturn(optionalNe);
182 ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW = new ONFCoreNetworkElement12Microwave(accessor,
183 serviceProvider, onfMicrowaveModel);
184 onfCoreNetworkElement12MW.prepareCheck();
186 EventlogEntity eventlogEntity = new EventlogEntity() {
189 public @Nullable String getId() {
190 // TODO Auto-generated method stub
195 public @Nullable DateAndTime getTimestamp() {
196 // TODO Auto-generated method stub
201 public @Nullable String getObjectId() {
202 // TODO Auto-generated method stub
207 public @Nullable String getNodeId() {
208 // TODO Auto-generated method stub
213 public @Nullable Integer getCounter() {
214 // TODO Auto-generated method stub
219 public @Nullable SourceType getSourceType() {
220 // TODO Auto-generated method stub
225 public @Nullable String getNewValue() {
226 // TODO Auto-generated method stub
231 public @Nullable String getAttributeName() {
232 // TODO Auto-generated method stub
233 return "/network-element/extension[value-name=\"top-level-equipment\"]/value"; // "/equipment-pac/equipment-current-problems";
237 public Class<? extends DataContainer> getImplementedInterface() {
238 // TODO Auto-generated method stub
243 onfCoreNetworkElement12MW.notificationActor(eventlogEntity);
251 when (accessor.getTransactionUtils().readData(accessor.getDataBroker(),
252 LogicalDatastoreType.OPERATIONAL, NETWORKELEMENT_IID)).thenReturn(null);
254 ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
255 new ONFCoreNetworkElement12Microwave(accessor, serviceProvider,
256 onfMicrowaveModel); onfCoreNetworkElement12MW.prepareCheck();
258 EventlogEntity eventlogEntity = new EventlogEntity() {
261 public @Nullable String getId() {
262 // TODO Auto-generated method stub
267 public @Nullable DateAndTime getTimestamp() {
268 // TODO Auto-generated method stub
273 public @Nullable String getObjectId() {
274 // TODO Auto-generated method stub
279 public @Nullable String getNodeId() {
280 // TODO Auto-generated method stub
285 public @Nullable Integer getCounter() {
286 // TODO Auto-generated method stub
291 public @Nullable SourceType getSourceType() {
292 // TODO Auto-generated method stub
297 public @Nullable String getNewValue() {
298 // TODO Auto-generated method stub
303 public @Nullable String getAttributeName() {
304 // TODO Auto-generated method stub
305 return "/equipment-pac/equipment-current-problems";
309 public Class<? extends DataContainer> getImplementedInterface() {
310 // TODO Auto-generated method stub
315 onfCoreNetworkElement12MW.notificationActor(eventlogEntity);