2 * Copyright © 2020 Orange Labs, Inc. and others. All rights reserved.
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
9 package org.opendaylight.transportpce.pce.constraints;
11 import static org.junit.jupiter.api.Assertions.assertThrows;
12 import static org.junit.jupiter.api.Assertions.assertTrue;
14 import java.util.NoSuchElementException;
15 import org.junit.jupiter.api.BeforeEach;
16 import org.junit.jupiter.api.Test;
17 import org.opendaylight.mdsal.binding.api.DataBroker;
18 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
19 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
20 import org.opendaylight.transportpce.pce.utils.PceTestData;
21 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
22 import org.opendaylight.transportpce.pce.utils.TransactionUtils;
23 import org.opendaylight.transportpce.test.AbstractTest;
25 public class PceConstraintsCalcTest extends AbstractTest {
26 private static NetworkTransactionService networkTransactionService = null;
27 private DataBroker dataBroker = getDataBroker();
29 //TODO: review this test class. May be miss few assert.
31 void setup() throws Exception {
32 // networkTransactionService = Mockito.mock(NetworkTransactionService.class);
33 PceTestUtils.writeNetworkIntoDataStore(dataBroker, getDataStoreContextUtil(),
34 TransactionUtils.getNetworkForSpanLoss());
35 networkTransactionService = new NetworkTransactionImpl(dataBroker);
39 void testNoHardOrSoftConstrainsExists() {
40 PceTestData.getPCE_test2_request_54().getSoftConstraints();
41 new PceConstraintsCalc(PceTestData.getEmptyPCERequest(), networkTransactionService);
45 void testHardConstrainsExists() {
46 new PceConstraintsCalc(
47 PceTestData.getPCE_simpletopology_test1_requestSetHardAndSoftConstrains(),
48 networkTransactionService);
52 void testHardConstrainsExists1() {
53 new PceConstraintsCalc(
54 PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral(),
55 networkTransactionService);
59 void testSoftConstrainsExists() {
60 new PceConstraintsCalc(PceTestData.getPCERequest(), networkTransactionService);
63 //TODO: See if this test is relevant.
65 void testHardConstrainsExists2() {
66 Exception exception = assertThrows(NoSuchElementException.class, () -> {
67 new PceConstraintsCalc(
68 PceTestData.build_diversity_from_request(PceTestData.getPCERequest()),
69 networkTransactionService);
71 assertTrue(exception.getMessage().contains("No value present"));
75 void testHardConstrainsExists3() {
76 new PceConstraintsCalc(PceTestData.getEmptyPCERequestServiceNameWithRequestId(), networkTransactionService);
80 void testHardConstrainsExists4() {
81 new PceConstraintsCalc(PceTestData.getPCE_test2_request_54(), networkTransactionService);