2 * Copyright (c) 2018 Orange and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package io.fd.honeycomb.transportpce.device.test;
18 import io.fd.honeycomb.transportpce.device.tools.DefaultDeviceFactory;
19 import io.fd.honeycomb.transportpce.test.common.DataStoreContext;
20 import io.fd.honeycomb.transportpce.test.common.DataStoreContextImpl;
23 import java.util.Arrays;
24 import java.util.Collection;
26 import org.junit.Assert;
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
29 import org.junit.runners.Parameterized;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
35 * Test to create {@link OrgOpenroadmDevice} object
36 * from xml file or String using Yangtools
38 * @author Martial COULIBALY ( martial.coulibaly@gfi.com ) on behalf of Orange
40 @RunWith(Parameterized.class)
41 public class CreateDeviceFromXMLFileTest {
42 private static final Logger LOG = LoggerFactory.getLogger(CreateDeviceFromXMLFileTest.class);
43 private static final String DEVICE_OPER_IN = "src/main/resources/honeycomb-minimal-resources/config/device/sample-config-ROADM.xml";
47 public CreateDeviceFromXMLFileTest(String xmlData) {
51 @Parameterized.Parameters
52 public static Collection<Object[]> stringXML() {
53 return Arrays.asList(new Object[][]{
54 {DeviceOperToConfig.getDeviceFromXML(DeviceOperToConfig.operToConfig())}
55 // {DeviceOperToConfig.operToConfig()}
61 * This test create instance of
62 * {@link OrgOpenroadmDevice} with String xml
63 * from {@link DeviceOperToConfig#operToConfig()}
64 * function as parameters.
66 * @throws NullPointerException
69 public void createDeviceFromString() throws NullPointerException {
70 OrgOpenroadmDevice result = null;
71 LOG.info("Parameterized string is : {}", xml);
72 DataStoreContext dataStoreContextUtil = new DataStoreContextImpl();
73 DefaultDeviceFactory defaultDeviceFactory = new DefaultDeviceFactory();
74 result = defaultDeviceFactory.createDefaultDevice(dataStoreContextUtil,xml);
76 LOG.info("result info : {}", result.getInfo().getNodeId());
77 Assert.assertEquals("ROADMA", result.getInfo().getNodeId());
79 LOG.info("Test Succeed");
84 * This test create Device from File
85 * located at {@link CreateDeviceFromXMLFileTest#DEVICE_OPER_IN}.
87 * @throws NullPointerException
90 public void createDeviceFromFile() throws NullPointerException{
91 LOG.info("test createDeviceFromFile ...");
92 OrgOpenroadmDevice result = null;
94 File device_data = new File(DEVICE_OPER_IN);
95 DataStoreContext dataStoreContextUtil = new DataStoreContextImpl();
96 DefaultDeviceFactory defaultDeviceFactory = new DefaultDeviceFactory();
97 result = defaultDeviceFactory.createDefaultDevice(dataStoreContextUtil,device_data);
99 LOG.info("result info : {}", result.getInfo().getNodeId());
100 Assert.assertEquals("ROADMA", result.getInfo().getNodeId());
102 LOG.info("Test Succeed");