Merge "Reactive remaining Junits tests for Al migration"
[transportpce.git] / pce / src / test / java / org / opendaylight / transportpce / pce / constraints / PceConstraintsCalcTest.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
9 package org.opendaylight.transportpce.pce.constraints;
10
11 import org.junit.Before;
12 import org.junit.Test;
13 import org.opendaylight.mdsal.binding.api.DataBroker;
14 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
15 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
16 import org.opendaylight.transportpce.common.network.RequestProcessor;
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 public class PceConstraintsCalcTest extends AbstractTest {
23     private static PceConstraintsCalc pceConstraintsCalc;
24     private static NetworkTransactionService networkTransactionService = null;
25     private DataBroker dataBroker = this.getDataBroker();
26
27     @Before
28     public void setup() throws Exception {
29         // networkTransactionService = Mockito.mock(NetworkTransactionService.class);
30         PceTestUtils.writeNetworkIntoDataStore(dataBroker, this.getDataStoreContextUtil(),
31                 TransactionUtils.getNetworkForSpanLoss());
32         networkTransactionService = new NetworkTransactionImpl(new RequestProcessor(dataBroker));
33
34
35     }
36
37     @Test
38     public void testNoHardOrSoftConstrainsExists() {
39         PceTestData.getPCE_test2_request_54().getSoftConstraints();
40         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
41                 .getEmptyPCERequest(), networkTransactionService);
42     }
43
44     @Test()
45     public void testHardConstrainsExists() {
46         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
47                 .getPCE_simpletopology_test1_requestSetHardAndSoftConstrains(), networkTransactionService);
48     }
49
50     @Test()
51     public void testHardConstrainsExists1() {
52         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
53                 .getPathComputationRequestInputWithCoRoutingOrGeneral(), networkTransactionService);
54     }
55
56     @Test
57     public void testSoftConstrainsExists() {
58         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
59                 .getPCERequest(), networkTransactionService);
60     }
61
62     @Test(expected = Exception.class)
63     public void testHardConstrainsExists2() {
64         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
65                 .build_diversity_from_request(PceTestData.getPCERequest()), networkTransactionService);
66     }
67
68     @Test()
69     public void testHardConstrainsExists3() {
70         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
71                 .getEmptyPCERequestServiceNameWithRequestId(), networkTransactionService);
72     }
73
74     @Test(expected = Exception.class)
75     public void testHardConstrainsExists4() {
76         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
77                 .getPCE_test2_request_54(), networkTransactionService);
78     }
79
80 }