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.Assert;
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.rev171017.PathComputationRequestInput;
27 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutput;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
31 @RunWith(value = Parameterized.class)
32 public class PceSingleTests extends AbstractTest {
34 private static final Logger LOG = LoggerFactory.getLogger(PceSingleTests.class);
36 private PathComputationRequestInput input;
37 private PathComputationRequestOutput expectedOutput;
38 private String topologyDataPath;
39 private NetworkModelWavelengthService networkModelWavelengthService;
40 private NotificationPublishService notificationPublishService;
42 @Parameterized.Parameters(name = "parameters")
43 public static Collection<Object[]> data() {
44 return Arrays.asList(new Object[][]{
45 { PceTestData.getEmptyPCERequest(), PceTestData.getFailedPCEResultYes(),
46 "topologyData/NW-for-test-5-4.xml" },
47 { PceTestData.getPCERequest(), PceTestData.getPCEResultOk((long)2),
48 "topologyData/NW-for-test-5-4.xml" },
49 { PceTestData.getPCE_test1_request_54(), PceTestData.getPCE_test_result_54((long)5),
50 "topologyData/NW-for-test-5-4.xml" },
51 { PceTestData.getPCE_test2_request_54(), PceTestData.getPCE_test_result_54((long)9),
52 "topologyData/NW-for-test-5-4.xml" },
53 { PceTestData.getPCE_test3_request_54(), PceTestData.getPCE_test_result_54((long)9),
54 "topologyData/NW-for-test-5-4.xml" }
59 * Input parameters for testPathCalculation.
62 * input path computation request
63 * @param expectedOutput
64 * expected path computation result
65 * @param topologyDataPath
66 * path to topology data file to be used for DataStore population
68 public PceSingleTests(PathComputationRequestInput input, PathComputationRequestOutput expectedOutput,
69 String topologyDataPath) {
71 this.expectedOutput = expectedOutput;
72 this.topologyDataPath = topologyDataPath;
73 this.networkModelWavelengthService = new NetworkModelWavelengthServiceImpl(getDataBroker());
74 this.notificationPublishService = new NotificationPublishServiceMock();
78 * This test runs single PCE calculation on the top one openroadm-topology.
79 * @throws Exception exception throws by the function
82 public void testPathCalculation() throws Exception {
83 LOG.info("testPathCalculation");
84 PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(), this.topologyDataPath);
86 PathComputationService pathComputationService =
87 new PathComputationServiceImpl(getDataBroker(), this.notificationPublishService);
88 PathComputationRequestOutput output = pathComputationService.pathComputationRequest(this.input);
90 PceTestUtils.checkConfigurationResponse(output, this.expectedOutput);
91 if (ResponseCodes.RESPONSE_OK.equals(output.getConfigurationResponseCommon().getResponseCode())) {
92 PceTestUtils.checkCalculatedPath(output, this.expectedOutput);
94 Assert.fail("Path calculation failed !");
96 LOG.info("test done");