c58489317b63eb1c7b0dcb0b3697123735c943fd
[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
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     }
47
48     @Test
49     public void testPceCalculationValues() {
50
51         pceCalculation.retrievePceNetwork();
52         Assert.assertEquals("100GE", pceCalculation.getServiceType());
53         Assert.assertNotNull(pceCalculation.getReturnStructure());
54
55         Assert.assertNull(pceCalculation.getaendPceNode());
56         Assert.assertNull(pceCalculation.getzendPceNode());
57     }
58
59     @Test
60     public void testPceCalculationValues2() {
61
62         pceCalculation = new PceCalculation(
63                 PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral(),
64                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
65                 pceConstraintsCalc.getPceHardConstraints(),
66                 pceConstraintsCalc.getPceSoftConstraints(),
67                 pceResult);
68         pceCalculation.retrievePceNetwork();
69         Assert.assertEquals("100GE", pceCalculation.getServiceType());
70         Assert.assertNotNull(pceCalculation.getReturnStructure());
71
72         Assert.assertNull(pceCalculation.getaendPceNode());
73         Assert.assertNull(pceCalculation.getzendPceNode());
74     }
75
76     @Test
77     public void testPceCalculationValues42() {
78
79         PathComputationRequestInput input = PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2();
80         pceConstraintsCalc = new PceConstraintsCalc(input,
81                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())));
82
83         pceCalculation = new PceCalculation(
84                 PceTestData.getPCE_test3_request_54(),
85                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
86                 pceConstraintsCalc.getPceHardConstraints(),
87                 pceConstraintsCalc.getPceSoftConstraints(),
88                 pceResult);
89
90         pceCalculation.retrievePceNetwork();
91 //        Assert.assertEquals("100GE", pceCalculation.getServiceType());
92         Assert.assertNotNull(pceCalculation.getReturnStructure());
93
94         Assert.assertNull(pceCalculation.getaendPceNode());
95         Assert.assertNull(pceCalculation.getzendPceNode());
96     }
97 }