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;
14 import org.junit.Assert;
15 import org.junit.Before;
16 import org.junit.Test;
18 import org.opendaylight.transportpce.pce.networkanalyzer.PceOpticalNode;
19 import org.opendaylight.transportpce.test.AbstractTest;
23 public class PceConstraintsTest extends AbstractTest {
24 private static PceConstraints pceConstraints = new PceConstraints();
28 pceConstraints = new PceConstraints();
32 public void setAndGetMaxLatencyTest() {
33 Assert.assertEquals(-1, this.pceConstraints.getMaxLatency().intValue());
34 pceConstraints.setMaxLatency(-2L);
35 Assert.assertEquals(-2, this.pceConstraints.getMaxLatency().intValue());
39 public void setAndGetExcludeSupNodesTest() {
40 Assert.assertEquals(0, this.pceConstraints.getExcludeSupNodes().size());
41 List<String> nodes = new ArrayList<>();
43 this.pceConstraints.setExcludeSupNodes(nodes);
44 Assert.assertEquals(1, this.pceConstraints.getExcludeSupNodes().size());
48 public void setAndGetExcludeSRLGTest() {
49 Assert.assertEquals(0, this.pceConstraints.getExcludeSRLG().size());
50 List<Long> nodes = new ArrayList<>();
52 this.pceConstraints.setExcludeSRLG(nodes);
53 Assert.assertEquals(1, this.pceConstraints.getExcludeSRLG().size());
57 public void setAndGetExcludeCLLITest() {
58 Assert.assertEquals(0, this.pceConstraints.getExcludeCLLI().size());
59 List<String> nodes = new ArrayList<>();
61 this.pceConstraints.setExcludeCLLI(nodes);
62 Assert.assertEquals(1, this.pceConstraints.getExcludeCLLI().size());
66 public void setAndGetExcludeClliNodesTest() {
67 Assert.assertEquals(0, this.pceConstraints.getExcludeClliNodes().size());
68 List<String> nodes = new ArrayList<>();
70 this.pceConstraints.setExcludeClliNodes(nodes);
71 Assert.assertEquals(1, this.pceConstraints.getExcludeClliNodes().size());
75 public void setAndGetExcludeSrlgLinksTest() {
76 Assert.assertEquals(0, this.pceConstraints.getExcludeSrlgLinks().size());
77 List<String> nodes = new ArrayList<>();
79 this.pceConstraints.setExcludeSrlgLinks(nodes);
80 Assert.assertEquals(1, this.pceConstraints.getExcludeSrlgLinks().size());
84 public void setAndGetExcludeNodesTest() {
85 Assert.assertEquals(0, this.pceConstraints.getExcludeNodes().size());
86 List<String> nodes = new ArrayList<>();
88 this.pceConstraints.setExcludeNodes(nodes);
89 Assert.assertEquals(1, this.pceConstraints.getExcludeNodes().size());
93 public void setAndGetIncludeNodesTest() {
94 Assert.assertEquals(0, this.pceConstraints.getIncludeNodes().size());
95 List<String> nodes = new ArrayList<>();
97 this.pceConstraints.setIncludeNodes(nodes);
98 Assert.assertEquals(1, this.pceConstraints.getIncludeNodes().size());
102 public void getTypeAndNameOfResourcePairTest() {
103 PceConstraints.ResourcePair resourcePair = new PceConstraints
104 .ResourcePair(PceConstraints.ResourceType.CLLI, "test");
105 Assert.assertEquals(resourcePair.getType(), PceConstraints.ResourceType.CLLI);
106 Assert.assertEquals("test", resourcePair.getName());
112 public void getIncludePceNodesTest() {
113 Assert.assertTrue(pceConstraints.getIncludePceNodes().size() == 0);
114 pceConstraints.setIncludePceNode(new PceOpticalNode(null, null, null, null, null));
115 Assert.assertTrue(pceConstraints.getIncludePceNodes().size() == 1);
120 public void getListToIncludeTest() {
121 Assert.assertTrue(pceConstraints.getListToInclude().size() == 0);
122 PceConstraints.ResourcePair resourcePair = new PceConstraints
123 .ResourcePair(PceConstraints.ResourceType.SRLG, "test");
124 pceConstraints.setListToInclude(resourcePair);
125 Assert.assertTrue(pceConstraints.getListToInclude().size() == 1);
126 Assert.assertTrue(pceConstraints.getSRLGnames().size() == 1);