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.network.NetworkTransactionImpl;
15 import org.opendaylight.transportpce.common.network.RequestProcessor;
16 import org.opendaylight.transportpce.pce.constraints.PceConstraintsCalc;
17 import org.opendaylight.transportpce.pce.utils.PceTestData;
18 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
19 import org.opendaylight.transportpce.pce.utils.TransactionUtils;
20 import org.opendaylight.transportpce.test.AbstractTest;
21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestInput;
23 public class PceCalculationTest extends AbstractTest {
25 private PceCalculation pceCalculation;
26 private PceConstraintsCalc pceConstraintsCalc;
27 private PceResult pceResult = new PceResult();
31 public void setUp() throws ExecutionException, InterruptedException {
32 pceResult.setRC("200");
33 PceTestUtils.writeNetworkIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil(),
34 TransactionUtils.getNetworkForSpanLoss());
36 pceConstraintsCalc = new PceConstraintsCalc(PceTestData.getPCERequest(),
37 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())));
39 pceCalculation = new PceCalculation(
40 PceTestData.getPCERequest(),
41 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
42 pceConstraintsCalc.getPceHardConstraints(),
43 pceConstraintsCalc.getPceSoftConstraints(),
48 public void testPceCalculationValues() {
50 pceCalculation.retrievePceNetwork();
51 Assert.assertEquals("100GE", pceCalculation.getServiceType());
52 Assert.assertNotNull(pceCalculation.getReturnStructure());
54 Assert.assertNull(pceCalculation.getaendPceNode());
55 Assert.assertNull(pceCalculation.getzendPceNode());
59 public void testPceCalculationValues2() {
61 pceCalculation = new PceCalculation(
62 PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral(),
63 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
64 pceConstraintsCalc.getPceHardConstraints(),
65 pceConstraintsCalc.getPceSoftConstraints(),
67 pceCalculation.retrievePceNetwork();
68 Assert.assertEquals("100GE", pceCalculation.getServiceType());
69 Assert.assertNotNull(pceCalculation.getReturnStructure());
71 Assert.assertNull(pceCalculation.getaendPceNode());
72 Assert.assertNull(pceCalculation.getzendPceNode());
76 public void testPceCalculationValues42() {
78 PathComputationRequestInput input = PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2();
79 pceConstraintsCalc = new PceConstraintsCalc(input,
80 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())));
82 pceCalculation = new PceCalculation(
83 PceTestData.getPCE_test3_request_54(),
84 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
85 pceConstraintsCalc.getPceHardConstraints(),
86 pceConstraintsCalc.getPceSoftConstraints(),
89 pceCalculation.retrievePceNetwork();
90 // Assert.assertEquals("100GE", pceCalculation.getServiceType());
91 Assert.assertNotNull(pceCalculation.getReturnStructure());
93 Assert.assertNull(pceCalculation.getaendPceNode());
94 Assert.assertNull(pceCalculation.getzendPceNode());