0e257e345cffc65fec20e60cf3214502034e109a
[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 import java.io.IOException;
24 import java.util.Optional;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanNetworkElementFactory;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
27 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
28 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
29 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
30 import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT;
31 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
32
33 public class TestORanNetworkElementFactory {
34
35     private static String NODEIDSTRING = "nSky";
36
37     private static NetconfBindingAccessor accessor;
38     private static DeviceManagerServiceProvider serviceProvider;
39     private static Capabilities capabilities;
40
41    // @BeforeClass
42     public static void init() throws InterruptedException, IOException {
43         NetconfBindingAccessor bindingCommunicator = mock(NetconfBindingAccessor.class);
44         NodeId nodeId = new NodeId(NODEIDSTRING);
45         when(bindingCommunicator.getTransactionUtils()).thenReturn(mock(TransactionUtils.class));
46         when(bindingCommunicator.getNodeId()).thenReturn(nodeId);
47
48         capabilities = mock(Capabilities.class);
49         accessor = mock(NetconfBindingAccessor.class);
50         serviceProvider = mock(DeviceManagerServiceProvider.class);
51
52         when(accessor.getCapabilites()).thenReturn(capabilities);
53         when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(bindingCommunicator));
54         when(serviceProvider.getDataProvider()).thenReturn(null);
55
56
57     }
58
59     //@Test
60     public void testCreateORANHWComponent() throws Exception {
61         when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true);
62         ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
63         assertTrue((factory.create(accessor, serviceProvider)).isPresent());
64     }
65
66     //@Test
67     public void testCreateNone() throws Exception {
68         when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false);
69         ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
70         assertTrue(!(factory.create(accessor, serviceProvider).isPresent()));
71     }
72
73     //@After
74     public void cleanUp() throws Exception {
75
76     }
77 }
78