199156e7128315e147c2b6a1f28325aff215dfd4
[oam.git] / features / devicemanager / x-ran / ru-fh / provider / src / test / java / org / onap / ccsdk / features / sdnr / wt / devicemanager / xran / TestXORanNetworkElementFactory.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.xran;
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.service.DeviceManagerServiceProvider;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.xran.mock.NetconfAccessorMock;
30 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
31 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
32 import org.opendaylight.yang.gen.v1.urn.xran.hardware._1._0.rev180720.XRANRADIO;
33 import org.opendaylight.yangtools.yang.common.QName;
34 import org.oransc.oam.features.devicemanager.xran.impl.XRanNetworkElementFactory;
35
36 public class TestXORanNetworkElementFactory {
37
38     static NetconfAccessor accessor;
39     static DeviceManagerServiceProvider serviceProvider;
40     static Capabilities capabilities;
41     QName qCapability;
42
43     @BeforeClass
44     public static void init() throws InterruptedException, IOException {
45         capabilities = mock(Capabilities.class);
46         accessor = mock(NetconfAccessorMock.class);
47         serviceProvider = mock(DeviceManagerServiceProvider.class);
48
49         when(accessor.getCapabilites()).thenReturn(capabilities);
50         when(serviceProvider.getDataProvider()).thenReturn(null);
51     }
52
53     @Test
54     public void testCreateORANHWComponent() throws Exception {
55         when(accessor.getCapabilites().isSupportingNamespace(XRANRADIO.QNAME)).thenReturn(true);
56         XRanNetworkElementFactory factory = new XRanNetworkElementFactory();
57         assertTrue(factory.create(accessor, serviceProvider).isPresent());
58     }
59
60     @Test
61     public void testCreateNone() throws Exception {
62         when(accessor.getCapabilites().isSupportingNamespace(XRANRADIO.QNAME)).thenReturn(false);
63         XRanNetworkElementFactory factory = new XRanNetworkElementFactory();
64         assertTrue(!factory.create(accessor, serviceProvider).isPresent());
65     }
66
67     @After
68     public void cleanUp() throws Exception {
69
70     }
71 }
72