improve test cases in PCE contraints
[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
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         pceConstraintsCalc = new PceConstraintsCalc(PceTestData.getPCERequest(),
36                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())));
37
38         pceCalculation = new PceCalculation(
39                 PceTestData.getPCERequest(),
40                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
41                 pceConstraintsCalc.getPceHardConstraints(),
42                 pceConstraintsCalc.getPceSoftConstraints(),
43                 pceResult);
44     }
45
46     @Test
47     public void testPceCalculationValues() {
48
49         pceCalculation.retrievePceNetwork();
50         Assert.assertEquals("100GE", pceCalculation.getServiceType());
51         Assert.assertNotNull(pceCalculation.getReturnStructure());
52
53         Assert.assertNull(pceCalculation.getaendPceNode());
54         Assert.assertNull(pceCalculation.getzendPceNode());
55     }
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 }