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.Test;
16 import org.opendaylight.transportpce.pce.networkanalyzer.PceOpticalNode;
17 import org.opendaylight.transportpce.test.AbstractTest;
19 public class PceConstraintsTest extends AbstractTest {
20 private static PceConstraints pceConstraints = new PceConstraints();
24 pceConstraints = new PceConstraints();
28 public void setAndGetMaxLatencyTest() {
29 Assert.assertEquals(-1, this.pceConstraints.getMaxLatency().intValue());
30 pceConstraints.setMaxLatency(-2L);
31 Assert.assertEquals(-2, this.pceConstraints.getMaxLatency().intValue());
35 public void setAndGetExcludeSupNodesTest() {
36 Assert.assertEquals(0, this.pceConstraints.getExcludeSupNodes().size());
37 List<String> nodes = new ArrayList<>();
39 this.pceConstraints.setExcludeSupNodes(nodes);
40 Assert.assertEquals(1, this.pceConstraints.getExcludeSupNodes().size());
44 public void setAndGetExcludeSRLGTest() {
45 Assert.assertEquals(0, this.pceConstraints.getExcludeSRLG().size());
46 List<Long> nodes = new ArrayList<>();
48 this.pceConstraints.setExcludeSRLG(nodes);
49 Assert.assertEquals(1, this.pceConstraints.getExcludeSRLG().size());
53 public void setAndGetExcludeCLLITest() {
54 Assert.assertEquals(0, this.pceConstraints.getExcludeCLLI().size());
55 List<String> nodes = new ArrayList<>();
57 this.pceConstraints.setExcludeCLLI(nodes);
58 Assert.assertEquals(1, this.pceConstraints.getExcludeCLLI().size());
62 public void setAndGetExcludeClliNodesTest() {
63 Assert.assertEquals(0, this.pceConstraints.getExcludeClliNodes().size());
64 List<String> nodes = new ArrayList<>();
66 this.pceConstraints.setExcludeClliNodes(nodes);
67 Assert.assertEquals(1, this.pceConstraints.getExcludeClliNodes().size());
71 public void setAndGetExcludeSrlgLinksTest() {
72 Assert.assertEquals(0, this.pceConstraints.getExcludeSrlgLinks().size());
73 List<String> nodes = new ArrayList<>();
75 this.pceConstraints.setExcludeSrlgLinks(nodes);
76 Assert.assertEquals(1, this.pceConstraints.getExcludeSrlgLinks().size());
80 public void setAndGetExcludeNodesTest() {
81 Assert.assertEquals(0, this.pceConstraints.getExcludeNodes().size());
82 List<String> nodes = new ArrayList<>();
84 this.pceConstraints.setExcludeNodes(nodes);
85 Assert.assertEquals(1, this.pceConstraints.getExcludeNodes().size());
89 public void setAndGetIncludeNodesTest() {
90 Assert.assertEquals(0, this.pceConstraints.getIncludeNodes().size());
91 List<String> nodes = new ArrayList<>();
93 this.pceConstraints.setIncludeNodes(nodes);
94 Assert.assertEquals(1, this.pceConstraints.getIncludeNodes().size());
98 public void getTypeAndNameOfResourcePairTest() {
99 PceConstraints.ResourcePair resourcePair = new PceConstraints
100 .ResourcePair(PceConstraints.ResourceType.CLLI, "test");
101 Assert.assertEquals(resourcePair.getType(), PceConstraints.ResourceType.CLLI);
102 Assert.assertEquals("test", resourcePair.getName());
108 public void getIncludePceNodesTest() {
109 Assert.assertTrue(pceConstraints.getIncludePceNodes().size() == 0);
110 pceConstraints.setIncludePceNode(new PceOpticalNode(null, null, null, null, null, null, null));
111 Assert.assertTrue(pceConstraints.getIncludePceNodes().size() == 1);
116 public void getListToIncludeTest() {
117 Assert.assertTrue(pceConstraints.getListToInclude().size() == 0);
118 PceConstraints.ResourcePair resourcePair = new PceConstraints
119 .ResourcePair(PceConstraints.ResourceType.SRLG, "test");
120 pceConstraints.setListToInclude(resourcePair);
121 Assert.assertTrue(pceConstraints.getListToInclude().size() == 1);
122 Assert.assertTrue(pceConstraints.getSRLGnames().size() == 1);