6713a78211e950b47935b5960ffd075597d013ac
[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.onf.impl.test;
19
20 import static org.junit.Assert.assertTrue;
21 import static org.mockito.Mockito.mock;
22 import static org.mockito.Mockito.when;
23
24 import java.io.IOException;
25 import org.junit.After;
26 import org.junit.BeforeClass;
27 import org.junit.Test;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev170324;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev180907;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev181010;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl.ONFCoreNetworkElementFactory;
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.NetconfAccessor;
35 import org.opendaylight.mdsal.binding.api.DataBroker;
36 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
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 TestONFCoreNetworkElementFactory {
41
42         static NetconfAccessor accessor;
43         static DeviceManagerServiceProvider serviceProvider;
44         static Capabilities capabilities;
45         static DataBroker dataBroker;
46         static NodeId nNodeId;
47         QName qCapability;
48
49         @BeforeClass
50         public static void init() throws InterruptedException, IOException {
51                 capabilities = mock(Capabilities.class);
52                 accessor = mock(NetconfAccessor.class);
53                 serviceProvider = mock(DeviceManagerServiceProvider.class);
54                 dataBroker = mock(DataBroker.class);
55                                 
56                 when(accessor.getCapabilites()).thenReturn(capabilities);
57                 //when(serviceProvider.getDataProvider()).thenReturn(dataProvider);
58                 nNodeId = new NodeId("nSky");
59                 when(accessor.getNodeId()).thenReturn(nNodeId);
60
61         
62         }
63
64         @Test
65         public void testCreateMWModelRev170324() throws Exception {
66                 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElement.QNAME)).thenReturn(true);
67                 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)).thenReturn(true);
68                 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)).thenReturn(false);
69                 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)).thenReturn(false);
70                 ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory();
71                 assertTrue((factory.create(accessor, serviceProvider)).isPresent());
72         }
73
74         @Test
75         public void testCreateMWModelRev180907() throws Exception {
76                 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElement.QNAME)).thenReturn(true);
77                 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)).thenReturn(false);
78                 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)).thenReturn(true);
79                 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)).thenReturn(false);
80                 ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory();
81                 assertTrue(factory.create(accessor, serviceProvider).isPresent());
82         }
83         
84         @Test
85         public void testCreateMWModelRev181010() throws Exception {
86                 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElement.QNAME)).thenReturn(true);
87                 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)).thenReturn(false);
88                 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)).thenReturn(false);
89                 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)).thenReturn(true);
90                 ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory();
91                 assertTrue(factory.create(accessor, serviceProvider).isPresent());
92         }
93         
94         @After
95         public void cleanUp() throws Exception {
96
97         }
98 }
99