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.Assert;
14 import org.junit.Test;
15 import org.junit.runner.RunWith;
16 import org.junit.runners.Parameterized;
17 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
18 import org.opendaylight.transportpce.common.ResponseCodes;
19 import org.opendaylight.transportpce.pce.service.PathComputationService;
20 import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
21 import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
22 import org.opendaylight.transportpce.pce.utils.PceTestData;
23 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
24 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
25 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthServiceImpl;
26 import org.opendaylight.transportpce.test.AbstractTest;
27 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestInput;
28 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
32 @RunWith(value = Parameterized.class)
33 public class PceSingleTests extends AbstractTest {
35 private static final Logger LOG = LoggerFactory.getLogger(PceSingleTests.class);
37 private PathComputationRequestInput input;
38 private PathComputationRequestOutput expectedOutput;
39 private String topologyDataPath;
40 private NetworkModelWavelengthService networkModelWavelengthService;
41 private NotificationPublishService notificationPublishService;
43 @Parameterized.Parameters(name = "parameters")
44 public static Collection<Object[]> data() {
45 return Arrays.asList(new Object[][]{
46 { PceTestData.getEmptyPCERequest(), PceTestData.getFailedPCEResultYes(),
47 "topologyData/NW-for-test-5-4.xml" },
48 { PceTestData.getPCERequest(), PceTestData.getPCEResultOk((long)2),
49 "topologyData/NW-for-test-5-4.xml" },
50 { PceTestData.getPCE_test1_request_54(), PceTestData.getPCE_test_result_54((long)5),
51 "topologyData/NW-for-test-5-4.xml" },
52 { PceTestData.getPCE_test2_request_54(), PceTestData.getPCE_test_result_54((long)9),
53 "topologyData/NW-for-test-5-4.xml" },
54 { PceTestData.getPCE_test3_request_54(), PceTestData.getPCE_test_result_54((long)9),
55 "topologyData/NW-for-test-5-4.xml" }
60 * Input parameters for testPathCalculation.
63 * input path computation request
64 * @param expectedOutput
65 * expected path computation result
66 * @param topologyDataPath
67 * path to topology data file to be used for DataStore population
69 public PceSingleTests(PathComputationRequestInput input, PathComputationRequestOutput expectedOutput,
70 String topologyDataPath) {
72 this.expectedOutput = expectedOutput;
73 this.topologyDataPath = topologyDataPath;
74 this.networkModelWavelengthService = new NetworkModelWavelengthServiceImpl(getDataBroker());
75 this.notificationPublishService = new NotificationPublishServiceMock();
79 * This test runs single PCE calculation on the top one openroadm-topology.
80 * @throws Exception exception throws by the function
83 public void testPathCalculation() throws Exception {
84 LOG.info("testPathCalculation");
85 PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(), this.topologyDataPath);
87 PathComputationService pathComputationService =
88 new PathComputationServiceImpl(getDataBroker(), this.notificationPublishService);
89 PathComputationRequestOutput output = pathComputationService.pathComputationRequest(this.input);
91 PceTestUtils.checkConfigurationResponse(output, this.expectedOutput);
92 if (ResponseCodes.RESPONSE_OK.equals(output.getConfigurationResponseCommon().getResponseCode())) {
93 PceTestUtils.checkCalculatedPath(output, this.expectedOutput);
95 Assert.fail("Path calculation failed !");
97 LOG.info("test done");