Create VES client example for domain 'notification'
[oam.git] / features / devicemanager / o-ran / ru-fh / provider / src / test / java / org / oransc / oam / features / devicemanager / oran / test / TestORanNetworkElementFactory.java
1 /*
2  * ============LICENSE_START========================================================================
3  * O-RAN-SC : oam/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.oransc.oam.features.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 import java.io.IOException;
24 import org.junit.After;
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
28 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
29 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
30 import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT;
31 import org.opendaylight.yangtools.yang.common.QName;
32 import org.oransc.oam.features.devicemanager.oran.impl.ORanNetworkElementFactory;
33 import org.oransc.oam.features.devicemanager.oran.test.mock.NetconfAccessorMock;
34
35 public class TestORanNetworkElementFactory {
36
37     static NetconfAccessor accessor;
38     static DeviceManagerServiceProvider serviceProvider;
39     static Capabilities capabilities;
40     QName qCapability;
41
42     @BeforeClass
43     public static void init() throws InterruptedException, IOException {
44         capabilities = mock(Capabilities.class);
45         accessor = mock(NetconfAccessorMock.class);
46         serviceProvider = mock(DeviceManagerServiceProvider.class);
47
48         when(accessor.getCapabilites()).thenReturn(capabilities);
49         when(serviceProvider.getDataProvider()).thenReturn(null);
50
51
52     }
53
54     @Test
55     public void testCreateORANHWComponent() throws Exception {
56         when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true);
57         ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
58         assertTrue((factory.create(accessor, serviceProvider)).isPresent());
59     }
60
61     @Test
62     public void testCreateNone() throws Exception {
63         when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false);
64         ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
65         assertTrue(!(factory.create(accessor, serviceProvider).isPresent()));
66     }
67
68     @After
69     public void cleanUp() throws Exception {
70
71     }
72 }
73