d067d538f292b3b173ec0d89ebbda70da7cc676c
[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.assertEquals;
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.dataprovider.model.DataProvider;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl.AdapterManagerNetworkElementFactory;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
33 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
34 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
35 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
36 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus;
37 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
38 import org.opendaylight.yangtools.yang.common.QName;
39
40 public class TestAdapterManagerNetworkElement {
41
42     static NetconfBindingAccessor accessor;
43     static DeviceManagerServiceProvider serviceProvider;
44     static Capabilities capabilities;
45     QName qCapability;
46
47     @BeforeClass
48     public static void init() throws InterruptedException, IOException {
49         capabilities = mock(Capabilities.class);
50         //accessor = mock(NetconfAccessorMock.class);
51         accessor = mock(NetconfBindingAccessor.class); //spy(new NetconfAccessorMock(null, null, null, null));
52         serviceProvider = mock(DeviceManagerServiceProvider.class);
53
54         NodeId nNodeId = new NodeId("nSky");
55         when(accessor.getCapabilites()).thenReturn(capabilities);
56         when(accessor.getNodeId()).thenReturn(nNodeId);
57         when(accessor.getTransactionUtils()).thenReturn(mock(TransactionUtils.class));
58
59         DataProvider dataProvider = mock(DataProvider.class);
60         when(serviceProvider.getDataProvider()).thenReturn(dataProvider);
61     }
62
63     @Test
64     public void test() {
65         Optional<NetworkElement> adapterManagerNe;
66         when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(true);
67         AdapterManagerNetworkElementFactory factory = new AdapterManagerNetworkElementFactory();
68         adapterManagerNe = factory.create(accessor, serviceProvider);
69         assertTrue(factory.create(accessor, serviceProvider).isPresent());
70         adapterManagerNe.get().register();
71         adapterManagerNe.get().deregister();
72         adapterManagerNe.get().getAcessor();
73         adapterManagerNe.get().getDeviceType();
74         assertEquals(adapterManagerNe.get().getNodeId().getValue(), "nSky");
75     }
76
77     @After
78     public void cleanUp() throws Exception {
79
80     }
81 }