db25465ebbb6ef5da4df91508e07dea82cfbb17f
[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.gran.test;
19
20 import static org.junit.Assert.*;
21 import static org.mockito.Mockito.mock;
22 import static org.mockito.Mockito.when;
23
24 import org.junit.Before;
25 import org.junit.Test;
26
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.GRanNetworkElementFactory;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
29 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
30 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
31 import org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.top.rev180731.TopGrp;
32
33
34 public class TestGRanNetworkElementFactory {
35
36         Capabilities capabilities;
37         NetconfAccessor netconfAccessor;
38         DeviceManagerServiceProvider devMgrService;
39         
40         @SuppressWarnings("unused")
41         @Before
42         public void init() {
43                 capabilities = mock(Capabilities.class);
44                 netconfAccessor = mock(NetconfAccessor.class);
45                 devMgrService = mock(DeviceManagerServiceProvider.class);
46                 
47                 when(netconfAccessor.getCapabilites()).thenReturn(capabilities);
48                 when(devMgrService.getDataProvider()).thenReturn(null);
49                 
50         }
51         
52         @Test
53         public void testCreate() throws Exception {
54                 when(netconfAccessor.getCapabilites().isSupportingNamespace(TopGrp.QNAME)).thenReturn(true);
55                 
56                 GRanNetworkElementFactory gRanNeFactory = new GRanNetworkElementFactory();
57                 assertTrue((gRanNeFactory.create(netconfAccessor, devMgrService)).isPresent());
58         }
59
60         @Test
61         public void testCreateNone() throws Exception {
62                 when(netconfAccessor.getCapabilites().isSupportingNamespace(TopGrp.QNAME)).thenReturn(false);
63                 
64                 GRanNetworkElementFactory gRanNeFactory = new GRanNetworkElementFactory();
65                 assertTrue(!(gRanNeFactory.create(netconfAccessor, devMgrService).isPresent()));
66         }
67
68 }