2 * Copyright © 2017 AT&T, Inc. and others. All rights reserved.
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
8 package org.opendaylight.transportpce.pce;
10 import java.util.Arrays;
11 import java.util.Collection;
12 import org.junit.Test;
13 import org.junit.runner.RunWith;
14 import org.junit.runners.Parameterized;
15 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
16 import org.opendaylight.transportpce.common.ResponseCodes;
17 import org.opendaylight.transportpce.pce.service.PathComputationService;
18 import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
19 import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
20 import org.opendaylight.transportpce.pce.utils.PceTestData;
21 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
22 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
23 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthServiceImpl;
24 import org.opendaylight.transportpce.test.AbstractTest;
25 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestInput;
26 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutput;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 @RunWith(value = Parameterized.class)
31 public class PceManyTests extends AbstractTest {
33 private static final Logger LOG = LoggerFactory.getLogger(PceManyTests.class);
35 private PathComputationRequestInput input;
36 private PathComputationRequestOutput expectedOutput;
37 private NetworkModelWavelengthService networkModelWavelengthService;
38 private NotificationPublishService notificationPublishService;
41 * Input parameters for testPathCalculation.
44 * input path computation request
45 * @param expectedOutput
46 * expected path computation result
47 * @param topologyDataPath
48 * path to topology data file to be used for DataStore population
50 * @throws Exception exception throws by the function
52 public PceManyTests(PathComputationRequestInput input,
53 PathComputationRequestOutput expectedOutput, String topologyDataPath) throws Exception {
55 this.expectedOutput = expectedOutput;
56 this.networkModelWavelengthService = new NetworkModelWavelengthServiceImpl(getDataBroker());
57 this.notificationPublishService = new NotificationPublishServiceMock();
58 PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(), topologyDataPath);
61 @Parameterized.Parameters(name = "parameters")
62 public static Collection<Object[]> data() {
63 return Arrays.asList(new Object[][]{
64 { PceTestData.getPCE_simpletopology_test1_request(),
65 PceTestData.getPCE_simpletopology_test1_result((long)5), "topologyData/NW-simple-topology.xml" }
70 * This test runs single PCE calculation on the top one openroadm-topology.
71 * @throws Exception exception throws by the function
74 public void testPathCalculations() throws Exception {
75 LOG.info("testPathCalculations");
77 PathComputationService pathComputationService =
78 new PathComputationServiceImpl(getDataBroker(), notificationPublishService);
79 PathComputationRequestOutput output = pathComputationService.pathComputationRequest(input);
81 PceTestUtils.checkConfigurationResponse(output, expectedOutput);
83 if (ResponseCodes.RESPONSE_OK.equals(output.getConfigurationResponseCommon().getResponseCode())) {
84 //networkModelWavelengthService.useWavelengths(output.getResponseParameters().getPathDescription());
85 PceTestUtils.checkCalculatedPath(output, expectedOutput);