2 * Copyright © 2020 Orange, 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 java.util.ArrayList;
12 import java.util.List;
13 import org.junit.Assert;
14 import org.junit.Before;
15 import org.junit.Ignore;
16 import org.junit.Test;
17 import org.opendaylight.transportpce.pce.networkanalyzer.PceOpticalNode;
18 import org.opendaylight.transportpce.test.AbstractTest;
21 public class PceConstraintsTest extends AbstractTest {
22 private static PceConstraints pceConstraints = new PceConstraints();
26 pceConstraints = new PceConstraints();
30 public void setAndGetMaxLatencyTest() {
31 Assert.assertEquals(-1, this.pceConstraints.getMaxLatency().intValue());
32 pceConstraints.setMaxLatency(-2L);
33 Assert.assertEquals(-2, this.pceConstraints.getMaxLatency().intValue());
37 public void setAndGetExcludeSupNodesTest() {
38 Assert.assertEquals(0, this.pceConstraints.getExcludeSupNodes().size());
39 List<String> nodes = new ArrayList<>();
41 this.pceConstraints.setExcludeSupNodes(nodes);
42 Assert.assertEquals(1, this.pceConstraints.getExcludeSupNodes().size());
46 public void setAndGetExcludeSRLGTest() {
47 Assert.assertEquals(0, this.pceConstraints.getExcludeSRLG().size());
48 List<Long> nodes = new ArrayList<>();
50 this.pceConstraints.setExcludeSRLG(nodes);
51 Assert.assertEquals(1, this.pceConstraints.getExcludeSRLG().size());
55 public void setAndGetExcludeCLLITest() {
56 Assert.assertEquals(0, this.pceConstraints.getExcludeCLLI().size());
57 List<String> nodes = new ArrayList<>();
59 this.pceConstraints.setExcludeCLLI(nodes);
60 Assert.assertEquals(1, this.pceConstraints.getExcludeCLLI().size());
64 public void setAndGetExcludeClliNodesTest() {
65 Assert.assertEquals(0, this.pceConstraints.getExcludeClliNodes().size());
66 List<String> nodes = new ArrayList<>();
68 this.pceConstraints.setExcludeClliNodes(nodes);
69 Assert.assertEquals(1, this.pceConstraints.getExcludeClliNodes().size());
73 public void setAndGetExcludeSrlgLinksTest() {
74 Assert.assertEquals(0, this.pceConstraints.getExcludeSrlgLinks().size());
75 List<String> nodes = new ArrayList<>();
77 this.pceConstraints.setExcludeSrlgLinks(nodes);
78 Assert.assertEquals(1, this.pceConstraints.getExcludeSrlgLinks().size());
82 public void setAndGetExcludeNodesTest() {
83 Assert.assertEquals(0, this.pceConstraints.getExcludeNodes().size());
84 List<String> nodes = new ArrayList<>();
86 this.pceConstraints.setExcludeNodes(nodes);
87 Assert.assertEquals(1, this.pceConstraints.getExcludeNodes().size());
91 public void setAndGetIncludeNodesTest() {
92 Assert.assertEquals(0, this.pceConstraints.getIncludeNodes().size());
93 List<String> nodes = new ArrayList<>();
95 this.pceConstraints.setIncludeNodes(nodes);
96 Assert.assertEquals(1, this.pceConstraints.getIncludeNodes().size());
100 public void getTypeAndNameOfResourcePairTest() {
101 PceConstraints.ResourcePair resourcePair = new PceConstraints
102 .ResourcePair(PceConstraints.ResourceType.CLLI, "test");
103 Assert.assertEquals(resourcePair.getType(), PceConstraints.ResourceType.CLLI);
104 Assert.assertEquals("test", resourcePair.getName());
110 public void getIncludePceNodesTest() {
111 Assert.assertTrue(pceConstraints.getIncludePceNodes().size() == 0);
112 pceConstraints.setIncludePceNode(new PceOpticalNode(null, null, null, null, null));
113 Assert.assertTrue(pceConstraints.getIncludePceNodes().size() == 1);
118 public void getListToIncludeTest() {
119 Assert.assertTrue(pceConstraints.getListToInclude().size() == 0);
120 PceConstraints.ResourcePair resourcePair = new PceConstraints
121 .ResourcePair(PceConstraints.ResourceType.SRLG, "test");
122 pceConstraints.setListToInclude(resourcePair);
123 Assert.assertTrue(pceConstraints.getListToInclude().size() == 1);
124 Assert.assertTrue(pceConstraints.getSRLGnames().size() == 1);