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;
13 import org.junit.Test;
14 import org.junit.runner.RunWith;
15 import org.junit.runners.Parameterized;
16 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
17 import org.opendaylight.transportpce.common.ResponseCodes;
18 import org.opendaylight.transportpce.pce.service.PathComputationService;
19 import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
20 import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
21 import org.opendaylight.transportpce.pce.utils.PceTestData;
22 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
23 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
24 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthServiceImpl;
25 import org.opendaylight.transportpce.test.AbstractTest;
26 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestInput;
27 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
31 @RunWith(value = Parameterized.class)
32 public class PceManyTests extends AbstractTest {
34 private static final Logger LOG = LoggerFactory.getLogger(PceManyTests.class);
36 private PathComputationRequestInput input;
37 private PathComputationRequestOutput expectedOutput;
38 private NetworkModelWavelengthService networkModelWavelengthService;
39 private NotificationPublishService notificationPublishService;
42 * Input parameters for testPathCalculation.
45 * input path computation request
46 * @param expectedOutput
47 * expected path computation result
48 * @param topologyDataPath
49 * path to topology data file to be used for DataStore population
51 * @throws Exception exception throws by the function
53 public PceManyTests(PathComputationRequestInput input,
54 PathComputationRequestOutput expectedOutput, String topologyDataPath) throws Exception {
56 this.expectedOutput = expectedOutput;
57 this.networkModelWavelengthService = new NetworkModelWavelengthServiceImpl(getDataBroker());
58 this.notificationPublishService = new NotificationPublishServiceMock();
59 PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(), topologyDataPath);
62 @Parameterized.Parameters(name = "parameters")
63 public static Collection<Object[]> data() {
64 return Arrays.asList(new Object[][]{
65 { PceTestData.getPCE_simpletopology_test1_request(),
66 PceTestData.getPCE_simpletopology_test1_result((long)5), "topologyData/NW-simple-topology.xml" }
71 * This test runs single PCE calculation on the top one openroadm-topology.
72 * @throws Exception exception throws by the function
75 public void testPathCalculations() throws Exception {
76 LOG.info("testPathCalculations");
78 PathComputationService pathComputationService =
79 new PathComputationServiceImpl(getDataBroker(), notificationPublishService);
80 PathComputationRequestOutput output = pathComputationService.pathComputationRequest(input);
82 PceTestUtils.checkConfigurationResponse(output, expectedOutput);
84 if (ResponseCodes.RESPONSE_OK.equals(output.getConfigurationResponseCommon().getResponseCode())) {
85 networkModelWavelengthService.useWavelengths(output.getResponseParameters().getPathDescription());
86 PceTestUtils.checkCalculatedPath(output, expectedOutput);