c861e9384fc03f28a2bed2e52d879c7d6613b921
[transportpce.git] / networkmodel / src / test / java / org / opendaylight / transportpce / networkmodel / service / NetworkModelWavelengthServiceTest.java
1 /*
2  * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.transportpce.networkmodel.service;
10
11 import static org.junit.Assert.fail;
12
13 import java.io.FileNotFoundException;
14 import java.io.FileReader;
15 import java.io.IOException;
16 import java.io.Reader;
17 import java.nio.charset.StandardCharsets;
18 import java.util.concurrent.ExecutionException;
19 import org.junit.BeforeClass;
20 import org.junit.Ignore;
21 import org.junit.Test;
22 import org.opendaylight.transportpce.common.InstanceIdentifiers;
23 import org.opendaylight.transportpce.test.AbstractTest;
24 import org.opendaylight.transportpce.test.converter.DataObjectConverter;
25 import org.opendaylight.transportpce.test.converter.JSONDataObjectConverter;
26 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
27 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.service.path.rpc.result.PathDescription;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31 @Ignore
32 //FIXME: disabled because some updates are needed on test-common
33 public class NetworkModelWavelengthServiceTest extends AbstractTest {
34     private static final Logger LOG = LoggerFactory.getLogger(NetworkModelWavelengthServiceTest.class);
35     private static final String OPENROADM_TOPOLOGY_FILE = "src/test/resources/openroadm-topology.xml";
36     private static final String PATH_DESCRIPTION_FILE = "src/test/resources/path_description.json";
37     private static DataObjectConverter dataObjectConverter;
38
39     @BeforeClass
40     public static void setUp() throws InterruptedException, ExecutionException, FileNotFoundException {
41         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(), OPENROADM_TOPOLOGY_FILE,
42                 InstanceIdentifiers.OVERLAY_NETWORK_II);
43         dataObjectConverter = JSONDataObjectConverter.createWithDataStoreUtil(getDataStoreContextUtil());
44     }
45
46     @Test
47     public void allocateFrequenciesTest() throws IOException {
48         try (Reader reader = new FileReader(PATH_DESCRIPTION_FILE, StandardCharsets.UTF_8)) {
49             PathDescription pathDescription = (PathDescription) dataObjectConverter.transformIntoNormalizedNode(reader)
50                     .get().getValue();
51             NetworkModelWavelengthService service = new NetworkModelWavelengthServiceImpl(getDataBroker());
52             service.allocateFrequencies(pathDescription.getAToZDirection(), pathDescription.getZToADirection());
53         } catch (IOException e) {
54             LOG.error("Cannot load path description ", e);
55             fail("Cannot load path description ");
56         }
57     }
58 }