c166694e06cf208c8c216e733c66e55a3f26600e
[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.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;
22
23 public class PceCalculationTest extends AbstractTest {
24
25     private PceCalculation pceCalculation;
26     private PceConstraintsCalc pceConstraintsCalc;
27     private PceResult pceResult = new PceResult();
28
29     // setup object
30     @Before
31     public void setUp() throws ExecutionException, InterruptedException {
32         pceResult.setRC("200");
33         PceTestUtils.writeNetworkIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil(),
34                 TransactionUtils.getNetworkForSpanLoss());
35
36         pceConstraintsCalc = new PceConstraintsCalc(PceTestData.getPCERequest(),
37                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())));
38
39         pceCalculation = new PceCalculation(
40                 PceTestData.getPCERequest(),
41                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
42                 pceConstraintsCalc.getPceHardConstraints(),
43                 pceConstraintsCalc.getPceSoftConstraints(),
44                 pceResult);
45     }
46
47     @Test
48     public void testPceCalculationValues() {
49
50         pceCalculation.retrievePceNetwork();
51         Assert.assertEquals("100GE", pceCalculation.getServiceType());
52         Assert.assertNotNull(pceCalculation.getReturnStructure());
53
54         Assert.assertNull(pceCalculation.getaendPceNode());
55         Assert.assertNull(pceCalculation.getzendPceNode());
56     }
57
58     @Test
59     public void testPceCalculationValues2() {
60
61         pceCalculation = new PceCalculation(
62                 PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral(),
63                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
64                 pceConstraintsCalc.getPceHardConstraints(),
65                 pceConstraintsCalc.getPceSoftConstraints(),
66                 pceResult);
67         pceCalculation.retrievePceNetwork();
68         Assert.assertEquals("100GE", pceCalculation.getServiceType());
69         Assert.assertNotNull(pceCalculation.getReturnStructure());
70
71         Assert.assertNull(pceCalculation.getaendPceNode());
72         Assert.assertNull(pceCalculation.getzendPceNode());
73     }
74
75     @Test
76     public void testPceCalculationValues42() {
77
78         PathComputationRequestInput input = PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2();
79         pceConstraintsCalc = new PceConstraintsCalc(input,
80                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())));
81
82         pceCalculation = new PceCalculation(
83                 PceTestData.getPCE_test3_request_54(),
84                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
85                 pceConstraintsCalc.getPceHardConstraints(),
86                 pceConstraintsCalc.getPceSoftConstraints(),
87                 pceResult);
88
89         pceCalculation.retrievePceNetwork();
90 //        Assert.assertEquals("100GE", pceCalculation.getServiceType());
91         Assert.assertNotNull(pceCalculation.getReturnStructure());
92
93         Assert.assertNull(pceCalculation.getaendPceNode());
94         Assert.assertNull(pceCalculation.getzendPceNode());
95     }
96 }