59e57da11ce05a322d8eb5c998897bc81fa39281
[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.onf14;
19
20 import static org.junit.Assert.assertTrue;
21 import java.io.IOException;
22 import org.junit.BeforeClass;
23 import org.junit.Test;
24 import org.mockito.Mockito;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.Onf14NetworkElementFactory;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.test.mock.NetconfAccessorMock;
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.onf.yang.core.model._1._4.rev191127.ControlConstruct;
31 import org.opendaylight.yangtools.yang.common.QName;
32
33 public class TestOnf14NetworkElementFactory extends Mockito {
34
35     static NetconfAccessor accessor;
36     static DeviceManagerServiceProvider serviceProvider;
37     static Capabilities capabilities;
38     QName qCapability;
39
40     @BeforeClass
41     public static void init() throws InterruptedException, IOException {
42         capabilities = mock(Capabilities.class);
43         accessor = mock(NetconfAccessorMock.class);
44         serviceProvider = mock(DeviceManagerServiceProvider.class);
45
46         when(accessor.getCapabilites()).thenReturn(capabilities);
47         when(serviceProvider.getDataProvider()).thenReturn(null);
48     }
49
50     @Test
51     public void testCreateOnf14Component() throws Exception {
52         when(accessor.getCapabilites().isSupportingNamespace(ControlConstruct.QNAME)).thenReturn(true);
53         Onf14NetworkElementFactory factory = new Onf14NetworkElementFactory();
54         assertTrue((factory.create(accessor, serviceProvider)).isPresent());
55     }
56
57     @Test
58     public void testCreateNone() throws Exception {
59         when(accessor.getCapabilites().isSupportingNamespace(ControlConstruct.QNAME)).thenReturn(false);
60         Onf14NetworkElementFactory factory = new Onf14NetworkElementFactory();
61         assertTrue(!(factory.create(accessor, serviceProvider).isPresent()));
62     }
63 }
64