2614e4dd751c1e2376cf21aed63b1b415a9fb4df
[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.oran.test;
19
20 import static org.junit.Assert.assertTrue;
21 import static org.mockito.Mockito.mock;
22 import static org.mockito.Mockito.when;
23
24 import java.io.IOException;
25 import org.junit.After;
26 import org.junit.BeforeClass;
27 import org.junit.Test;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanNetworkElementFactory;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock.NetconfAccessorMock;
31 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
32 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
33 import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT;
34 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus;
35 import org.opendaylight.yangtools.yang.common.QName;
36
37 public class TestORanNetworkElementFactory {
38
39     static NetconfAccessor accessor;
40     static DeviceManagerServiceProvider serviceProvider;
41     static Capabilities capabilities;
42     QName qCapability;
43
44     @BeforeClass
45     public static void init() throws InterruptedException, IOException {
46         capabilities = mock(Capabilities.class);
47         accessor = mock(NetconfAccessorMock.class);
48         serviceProvider = mock(DeviceManagerServiceProvider.class);
49
50         when(accessor.getCapabilites()).thenReturn(capabilities);
51         when(serviceProvider.getDataProvider()).thenReturn(null);
52
53
54     }
55
56     @Test
57     public void testCreateORANHWComponent() throws Exception {
58         when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true);
59         when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false);
60         ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
61         assertTrue((factory.create(accessor, serviceProvider)).isPresent());
62     }
63
64     @Test
65     public void testCreateSimulator() throws Exception {
66         when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false);
67         when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(true);
68         ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
69         assertTrue(factory.create(accessor, serviceProvider).isPresent());
70     }
71
72     @Test
73     public void testCreateNone() throws Exception {
74         when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false);
75         when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false);
76         ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
77         assertTrue(!(factory.create(accessor, serviceProvider).isPresent()));
78     }
79
80     @After
81     public void cleanUp() throws Exception {
82
83     }
84 }
85