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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
16 * ============LICENSE_END==========================================================================
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl.test;
20 import static org.junit.Assert.assertTrue;
21 import static org.mockito.Mockito.mock;
22 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.AfterClass;
28 import org.junit.BeforeClass;
29 import org.junit.Test;
30 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev170324;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev180907;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev181010;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl.DeviceManagerOnfConfiguration;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl.ONFCoreNetworkElementFactory;
36 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
37 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
38 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
39 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNotifications;
40 import org.opendaylight.mdsal.binding.api.DataBroker;
41 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
42 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
43 import org.opendaylight.yangtools.yang.common.QName;
45 public class TestONFCoreNetworkElementFactory {
47 static NetconfBindingAccessor accessor;
48 static DeviceManagerServiceProvider serviceProvider;
49 static Capabilities capabilities;
50 static DataBroker dataBroker;
51 static NodeId nNodeId;
52 static DeviceManagerOnfConfiguration configuration;
54 static File configFile;
58 public static void init() throws InterruptedException, IOException {
60 capabilities = mock(Capabilities.class);
61 accessor = mock(NetconfBindingAccessor.class);
62 serviceProvider = mock(DeviceManagerServiceProvider.class);
63 dataBroker = mock(DataBroker.class);
65 configFile = new File("devicemanager.properties");
66 ConfigurationFileRepresentation configFileRep = new ConfigurationFileRepresentation(configFile);
67 configuration = new DeviceManagerOnfConfiguration(configFileRep);
69 when(accessor.getCapabilites()).thenReturn(capabilities);
70 //when(serviceProvider.getDataProvider()).thenReturn(dataProvider);
71 nNodeId = new NodeId("nSky");
72 NetconfBindingAccessor bindingAccessor = mock(NetconfBindingAccessor.class);
73 when(bindingAccessor.getNodeId()).thenReturn(nNodeId);
74 when(bindingAccessor.getNotificationAccessor()).thenReturn(Optional.of(mock(NetconfNotifications.class)));
75 when(bindingAccessor.getCapabilites()).thenReturn(capabilities);
77 when(accessor.getNodeId()).thenReturn(nNodeId);
78 when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(bindingAccessor));
79 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElement.QNAME)).thenReturn(true);
84 public static void after() {
89 public void testCreateMWModelRev170324() throws Exception {
90 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME))
92 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME))
94 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME))
96 ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory(configuration);
97 assertTrue(factory.create(accessor, serviceProvider).isPresent());
101 public void testCreateMWModelRev180907() throws Exception {
102 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME))
104 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME))
106 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME))
108 ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory(configuration);
109 assertTrue(factory.create(accessor, serviceProvider).isPresent());
113 public void testCreateMWModelRev181010() throws Exception {
114 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME))
116 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME))
118 when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME))
120 ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory(configuration);
121 assertTrue(factory.create(accessor, serviceProvider).isPresent());
125 public void cleanUp() throws Exception {