improve test cases in PCE contraints
[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.DataStoreContext;
15 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
16 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
17 import org.opendaylight.transportpce.common.network.RequestProcessor;
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
23 public class PceConstraintsCalcTest extends AbstractTest {
24     private static PceConstraintsCalc pceConstraintsCalc = null;
25     private static NetworkTransactionService networkTransactionService = null;
26     private DataStoreContext dataStoreContext = this.getDataStoreContextUtil();
27     private DataBroker dataBroker = this.getDataBroker();
28
29     @Before
30     public void setup() throws Exception {
31         // networkTransactionService = Mockito.mock(NetworkTransactionService.class);
32         PceTestUtils.writeNetworkIntoDataStore(dataBroker, this.getDataStoreContextUtil(),
33                 TransactionUtils.getNetworkForSpanLoss());
34         networkTransactionService = new NetworkTransactionImpl(new RequestProcessor(dataBroker));
35
36
37     }
38
39     @Test
40     public void testNoHardOrSoftConstrainsExists() {
41         PceTestData.getPCE_test2_request_54().getSoftConstraints();
42         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
43                 .getEmptyPCERequest(), networkTransactionService);
44     }
45
46     @Test()
47     public void testHardConstrainsExists() {
48         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
49                 .getPCE_simpletopology_test1_requestSetHardAndSoftConstrains(), networkTransactionService);
50     }
51
52     @Test()
53     public void testHardConstrainsExists1() {
54         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
55                 .getPathComputationRequestInputWithCoRoutingOrGeneral(), networkTransactionService);
56     }
57
58     @Test
59     public void testSoftConstrainsExists() {
60         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
61                 .getPCERequest(), networkTransactionService);
62     }
63
64     @Test(expected = Exception.class)
65     public void testHardConstrainsExists2() {
66         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
67                 .build_diversity_from_request(PceTestData.getPCERequest()), networkTransactionService);
68     }
69
70     @Test()
71     public void testHardConstrainsExists3() {
72         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
73                 .getEmptyPCERequestServiceNameWithRequestId(), networkTransactionService);
74     }
75
76     @Test(expected = Exception.class)
77     public void testHardConstrainsExists4() {
78         pceConstraintsCalc = new PceConstraintsCalc(PceTestData
79                 .getPCE_test2_request_54(), networkTransactionService);
80     }
81
82 }