9f67e188e1a193bbda6b8d29d757d1f8b05bff42
[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.adaptermanager.test;
19
20 import static org.junit.Assert.assertFalse;
21 import static org.junit.Assert.assertTrue;
22 import static org.mockito.Mockito.mock;
23 import static org.mockito.Mockito.when;
24 import java.io.IOException;
25 import java.util.Optional;
26 import org.junit.After;
27 import org.junit.BeforeClass;
28 import org.junit.Test;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl.AdapterManagerNetworkElementFactory;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
31 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
32 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
33 import org.opendaylight.yang.gen.v1.urn.o.ran.sc.params.xml.ns.yang.nts.manager.rev210608.simulation.NetworkFunctions;
34 import org.opendaylight.yangtools.yang.common.QName;
35
36 public class TestAdapterManagerNetworkElementFactory {
37
38     static NetconfBindingAccessor 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(NetconfBindingAccessor.class);
47         serviceProvider = mock(DeviceManagerServiceProvider.class);
48
49         when(accessor.getCapabilites()).thenReturn(capabilities);
50         when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(accessor));
51         when(serviceProvider.getDataProvider()).thenReturn(null);
52     }
53
54     @Test
55     public void testCreateSimulator() throws Exception {
56         when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkFunctions.QNAME)).thenReturn(true);
57         AdapterManagerNetworkElementFactory factory = new AdapterManagerNetworkElementFactory();
58         assertTrue(factory.create(accessor, serviceProvider).isPresent());
59     }
60
61     @Test
62     public void testCreateNone() throws Exception {
63         when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkFunctions.QNAME)).thenReturn(false);
64         AdapterManagerNetworkElementFactory factory = new AdapterManagerNetworkElementFactory();
65         assertFalse(factory.create(accessor, serviceProvider).isPresent());
66     }
67
68     @After
69     public void cleanUp() throws Exception {
70
71     }
72 }
73