update devicemanager onf
[ccsdk/features.git] / sdnr / wt / devicemanager-onf / provider / src / test / java / org / onap / ccsdk / features / sdnr / wt / devicemanager / onf / ne / test / TestONFCoreNetworkElement12Basic.java
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.ONFCoreNetworkElement12Basic;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Microwave;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
34 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
35 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
36 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
37 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
39 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeControl;
40 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeState;
41 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LifecycleState;
42 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
43 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.OperationalState;
44 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
45 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension;
46 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.global._class.g.LocalId;
47 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.label.g.Label;
48 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.name.g.Name;
49 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Fd;
50 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Ltp;
51 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
54 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
55 import org.opendaylight.yangtools.yang.binding.Augmentation;
56 import org.opendaylight.yangtools.yang.binding.DataContainer;
57 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
58
59 public class TestONFCoreNetworkElement12Basic {
60
61     NetconfAccessor accessor;
62     DeviceManagerServiceProvider serviceProvider;
63     Capabilities capabilities;
64     TransactionUtils transactionUtils;
65     NetworkElement optionalNe;
66     OnfMicrowaveModel onfMicrowaveModel;
67     FaultService faultService;
68     EquipmentService equipmentService;
69     DeviceManagerOnfConfiguration configuration;
70
71     protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID =
72             InstanceIdentifier.builder(NetworkElement.class).build();
73
74     @Before
75     public void init() {
76         accessor = mock(NetconfAccessor.class);
77         serviceProvider = mock(DeviceManagerServiceProvider.class);
78         capabilities = mock(Capabilities.class);
79         transactionUtils = mock(TransactionUtils.class);
80         onfMicrowaveModel = mock(OnfMicrowaveModel.class);
81         faultService = mock(FaultService.class);
82         equipmentService = mock(EquipmentService.class);
83         configuration = mock(DeviceManagerOnfConfiguration.class);
84
85         when(accessor.getCapabilites()).thenReturn(capabilities);
86         when(serviceProvider.getFaultService()).thenReturn(faultService);
87         when(serviceProvider.getEquipmentService()).thenReturn(equipmentService);
88
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);
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 }