Adapt PCE to compute a 400GE path
[transportpce.git] / pce / src / test / java / org / opendaylight / transportpce / pce / networkanalyzer / PceCalculationTest.java
1 /*
2  * Copyright © 2020 Orange Labs, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.transportpce.pce.networkanalyzer;
9
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;
23
24 public class PceCalculationTest extends AbstractTest {
25
26     private PceCalculation pceCalculation;
27     private PceConstraintsCalc pceConstraintsCalc;
28     private PceResult pceResult = new PceResult();
29
30     // setup object
31     @Before
32     public void setUp() throws ExecutionException, InterruptedException {
33         pceResult.setRC("200");
34         PceTestUtils.writeNetworkIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil(),
35                 TransactionUtils.getNetworkForSpanLoss());
36
37         pceConstraintsCalc = new PceConstraintsCalc(PceTestData.getPCERequest(),
38                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())));
39
40         pceCalculation = new PceCalculation(
41                 PceTestData.getPCERequest(),
42                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
43                 pceConstraintsCalc.getPceHardConstraints(),
44                 pceConstraintsCalc.getPceSoftConstraints(),
45                 pceResult,
46                 null);
47     }
48
49     @Test
50     public void testPceCalculationValues() {
51
52         pceCalculation.retrievePceNetwork();
53         Assert.assertEquals(StringConstants.SERVICE_TYPE_100GE, pceCalculation.getServiceType());
54         Assert.assertNotNull(pceCalculation.getReturnStructure());
55
56         Assert.assertNull(pceCalculation.getaendPceNode());
57         Assert.assertNull(pceCalculation.getzendPceNode());
58     }
59
60     @Test
61     public void testPceCalculationValues2() {
62
63         pceCalculation = new PceCalculation(
64                 PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral(),
65                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
66                 pceConstraintsCalc.getPceHardConstraints(),
67                 pceConstraintsCalc.getPceSoftConstraints(),
68                 pceResult, null);
69         pceCalculation.retrievePceNetwork();
70         Assert.assertEquals(StringConstants.SERVICE_TYPE_100GE, pceCalculation.getServiceType());
71         Assert.assertNotNull(pceCalculation.getReturnStructure());
72
73         Assert.assertNull(pceCalculation.getaendPceNode());
74         Assert.assertNull(pceCalculation.getzendPceNode());
75     }
76
77     @Test
78     public void testPceCalculationValues42() {
79
80         PathComputationRequestInput input = PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2();
81         pceConstraintsCalc = new PceConstraintsCalc(input,
82                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())));
83
84         pceCalculation = new PceCalculation(
85                 PceTestData.getPCE_test3_request_54(),
86                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
87                 pceConstraintsCalc.getPceHardConstraints(),
88                 pceConstraintsCalc.getPceSoftConstraints(),
89                 pceResult, null);
90
91         pceCalculation.retrievePceNetwork();
92 //        Assert.assertEquals(StringConstants.SERVICE_TYPE_100GE, pceCalculation.getServiceType());
93         Assert.assertNotNull(pceCalculation.getReturnStructure());
94
95         Assert.assertNull(pceCalculation.getaendPceNode());
96         Assert.assertNull(pceCalculation.getzendPceNode());
97     }
98 }