2 * Copyright © 2020 Orange Labs, 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.networkanalyzer;
10 import java.util.concurrent.ExecutionException;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.transportpce.common.StringConstants;
15 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
16 import org.opendaylight.transportpce.common.network.RequestProcessor;
17 import org.opendaylight.transportpce.pce.constraints.PceConstraintsCalc;
18 import org.opendaylight.transportpce.pce.utils.PceTestData;
19 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
20 import org.opendaylight.transportpce.pce.utils.TransactionUtils;
21 import org.opendaylight.transportpce.test.AbstractTest;
22 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestInput;
24 public class PceCalculationTest extends AbstractTest {
26 private PceCalculation pceCalculation;
27 private PceConstraintsCalc pceConstraintsCalc;
28 private PceResult pceResult = new PceResult();
32 public void setUp() throws ExecutionException, InterruptedException {
33 pceResult.setRC("200");
34 PceTestUtils.writeNetworkIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil(),
35 TransactionUtils.getNetworkForSpanLoss());
37 pceConstraintsCalc = new PceConstraintsCalc(PceTestData.getPCERequest(),
38 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())));
40 pceCalculation = new PceCalculation(
41 PceTestData.getPCERequest(),
42 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
43 pceConstraintsCalc.getPceHardConstraints(),
44 pceConstraintsCalc.getPceSoftConstraints(),
50 public void testPceCalculationValues() {
52 pceCalculation.retrievePceNetwork();
53 Assert.assertEquals(StringConstants.SERVICE_TYPE_100GE, pceCalculation.getServiceType());
54 Assert.assertNotNull(pceCalculation.getReturnStructure());
56 Assert.assertNull(pceCalculation.getaendPceNode());
57 Assert.assertNull(pceCalculation.getzendPceNode());
61 public void testPceCalculationValues2() {
63 pceCalculation = new PceCalculation(
64 PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral(),
65 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
66 pceConstraintsCalc.getPceHardConstraints(),
67 pceConstraintsCalc.getPceSoftConstraints(),
69 pceCalculation.retrievePceNetwork();
70 Assert.assertEquals(StringConstants.SERVICE_TYPE_100GE, pceCalculation.getServiceType());
71 Assert.assertNotNull(pceCalculation.getReturnStructure());
73 Assert.assertNull(pceCalculation.getaendPceNode());
74 Assert.assertNull(pceCalculation.getzendPceNode());
78 public void testPceCalculationValues42() {
80 PathComputationRequestInput input = PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2();
81 pceConstraintsCalc = new PceConstraintsCalc(input,
82 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())));
84 pceCalculation = new PceCalculation(
85 PceTestData.getPCE_test3_request_54(),
86 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
87 pceConstraintsCalc.getPceHardConstraints(),
88 pceConstraintsCalc.getPceSoftConstraints(),
91 pceCalculation.retrievePceNetwork();
92 // Assert.assertEquals(StringConstants.SERVICE_TYPE_100GE, pceCalculation.getServiceType());
93 Assert.assertNotNull(pceCalculation.getReturnStructure());
95 Assert.assertNull(pceCalculation.getaendPceNode());
96 Assert.assertNull(pceCalculation.getzendPceNode());