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.onf14.dom;
20 import static org.junit.Assert.assertTrue;
22 import java.io.IOException;
23 import java.util.Optional;
24 import org.junit.AfterClass;
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27 import org.mockito.Mockito;
28 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
29 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.Onf14DomNetworkElementFactory;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
34 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
35 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
36 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
37 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
39 public class TestOnf14NetworkElementFactory extends Mockito {
41 private static NetconfAccessor accessor;
42 private static Optional<NetconfDomAccessor> domAccessor;
43 private static Capabilities capabilities;
44 private static DeviceManagerServiceProvider serviceProvider;
45 private static ConfigurationFileRepresentation configurationRepresentation;
46 private static String filename = "test.properties";
50 public static void init() throws InterruptedException, IOException {
51 capabilities = mock(Capabilities.class);
52 accessor = mock(NetconfAccessor.class);
53 domAccessor = Optional.of(mock(NetconfDomAccessor.class));
54 serviceProvider = mock(DeviceManagerServiceProvider.class);
56 when(accessor.getCapabilites()).thenReturn(capabilities);
57 when(serviceProvider.getDataProvider()).thenReturn(mock(DataProvider.class));
58 when(serviceProvider.getFaultService()).thenReturn(mock(FaultService.class));
63 public void testCreateOnf14Dom() throws Exception {
64 when(accessor.getCapabilites().isSupportingNamespace(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER)).thenReturn(true);
65 when(accessor.getNetconfDomAccessor()).thenReturn(domAccessor);
66 Onf14DomNetworkElementFactory factory = new Onf14DomNetworkElementFactory();
67 factory.init(serviceProvider);
68 assertTrue((factory.create(accessor, serviceProvider)).isPresent());
72 public void testCreateNone() throws Exception {
73 when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(mock(NetconfBindingAccessor.class)));
74 when(accessor.getCapabilites().isSupportingNamespace(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER)).thenReturn(false);
75 Onf14DomNetworkElementFactory factory = new Onf14DomNetworkElementFactory();
76 assertTrue(factory.create(accessor, serviceProvider).isEmpty());
80 public static void cleanUp() {
81 File file = new File(filename);
83 System.out.println("File exists, Deleting it");