5f101b031391aa0f44e9a393b10f0c74d8653c65
[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
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;
57
58 public class TestONFCoreNetworkElement12Microwave {
59
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;
69
70     protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID =
71             InstanceIdentifier.builder(NetworkElement.class).build();
72
73     @Before
74     public void init() {
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);
83
84         when(accessor.getCapabilites()).thenReturn(capabilities);
85         when(serviceProvider.getFaultService()).thenReturn(faultService);
86         when(serviceProvider.getEquipmentService()).thenReturn(equipmentService);
87
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);
92
93     }
94
95     @Test
96     public void test() {
97         optionalNe = mock(NetworkElement.class);
98
99         when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
100                 NETWORKELEMENT_IID)).thenReturn(optionalNe);
101
102         ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
103                 new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration, onfMicrowaveModel);
104         onfCoreNetworkElement12MW.prepareCheck();
105
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");
109
110         onfCoreNetworkElement12MW.notificationActor(eventlogEntity);
111
112     }
113
114
115     @Test
116     public void test1() {
117         when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
118                 NETWORKELEMENT_IID)).thenReturn(null);
119
120         ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
121                 new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration, onfMicrowaveModel);
122         onfCoreNetworkElement12MW.prepareCheck();
123
124         EventlogEntity eventlogEntity = mock(EventlogEntity.class);
125         when(eventlogEntity.getObjectId()).thenReturn("ABCD");
126         when(eventlogEntity.getAttributeName()).thenReturn("/equipment-pac/equipment-current-problems");
127
128         onfCoreNetworkElement12MW.notificationActor(eventlogEntity);
129     }
130
131
132 }