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