a3b994c05ceb9086a5a0cd6aef59c1250adf67ee
[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.pce.utils.PceTestData;
17 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
18 import org.opendaylight.transportpce.pce.utils.TransactionUtils;
19 import org.opendaylight.transportpce.test.AbstractTest;
20
21 public class PceConstraintsCalcTest extends AbstractTest {
22     private static NetworkTransactionService networkTransactionService = null;
23     private DataBroker dataBroker = getDataBroker();
24
25     //TODO: review this test class. May be miss few assert.
26     @Before
27     public void setup() throws Exception {
28         // networkTransactionService = Mockito.mock(NetworkTransactionService.class);
29         PceTestUtils.writeNetworkIntoDataStore(dataBroker, getDataStoreContextUtil(),
30                 TransactionUtils.getNetworkForSpanLoss());
31         networkTransactionService = new NetworkTransactionImpl(dataBroker);
32     }
33
34     @Test
35     public void testNoHardOrSoftConstrainsExists() {
36         PceTestData.getPCE_test2_request_54().getSoftConstraints();
37         new PceConstraintsCalc(PceTestData.getEmptyPCERequest(), networkTransactionService);
38     }
39
40     @Test()
41     public void testHardConstrainsExists() {
42         new PceConstraintsCalc(
43             PceTestData.getPCE_simpletopology_test1_requestSetHardAndSoftConstrains(),
44             networkTransactionService);
45     }
46
47     @Test()
48     public void testHardConstrainsExists1() {
49         new PceConstraintsCalc(
50             PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral(),
51             networkTransactionService);
52     }
53
54     @Test
55     public void testSoftConstrainsExists() {
56         new PceConstraintsCalc(PceTestData.getPCERequest(), networkTransactionService);
57     }
58
59     @Test(expected = Exception.class)
60     public void testHardConstrainsExists2() {
61         new PceConstraintsCalc(
62             PceTestData.build_diversity_from_request(PceTestData.getPCERequest()),
63             networkTransactionService);
64     }
65
66     @Test()
67     public void testHardConstrainsExists3() {
68         new PceConstraintsCalc(PceTestData.getEmptyPCERequestServiceNameWithRequestId(), networkTransactionService);
69     }
70
71     @Test()
72     public void testHardConstrainsExists4() {
73         new PceConstraintsCalc(PceTestData.getPCE_test2_request_54(), networkTransactionService);
74     }
75
76 }