Adapt PCE to compute a 400GE path
[transportpce.git] / pce / src / test / java / org / opendaylight / transportpce / pce / constraints / PceConstraintsTest.java
1 /*
2  * Copyright © 2020 Orange, 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 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;
18
19 public class PceConstraintsTest extends AbstractTest {
20     private static PceConstraints pceConstraints = new PceConstraints();
21
22     @Before
23     public void setup() {
24         pceConstraints = new PceConstraints();
25     }
26
27     @Test
28     public void setAndGetMaxLatencyTest() {
29         Assert.assertEquals(-1, this.pceConstraints.getMaxLatency().intValue());
30         pceConstraints.setMaxLatency(-2L);
31         Assert.assertEquals(-2, this.pceConstraints.getMaxLatency().intValue());
32     }
33
34     @Test
35     public void setAndGetExcludeSupNodesTest() {
36         Assert.assertEquals(0, this.pceConstraints.getExcludeSupNodes().size());
37         List<String> nodes = new ArrayList<>();
38         nodes.add("test");
39         this.pceConstraints.setExcludeSupNodes(nodes);
40         Assert.assertEquals(1, this.pceConstraints.getExcludeSupNodes().size());
41     }
42
43     @Test
44     public void setAndGetExcludeSRLGTest() {
45         Assert.assertEquals(0, this.pceConstraints.getExcludeSRLG().size());
46         List<Long> nodes = new ArrayList<>();
47         nodes.add(1L);
48         this.pceConstraints.setExcludeSRLG(nodes);
49         Assert.assertEquals(1, this.pceConstraints.getExcludeSRLG().size());
50     }
51
52     @Test
53     public void setAndGetExcludeCLLITest() {
54         Assert.assertEquals(0, this.pceConstraints.getExcludeCLLI().size());
55         List<String> nodes = new ArrayList<>();
56         nodes.add("test");
57         this.pceConstraints.setExcludeCLLI(nodes);
58         Assert.assertEquals(1, this.pceConstraints.getExcludeCLLI().size());
59     }
60
61     @Test
62     public void setAndGetExcludeClliNodesTest() {
63         Assert.assertEquals(0, this.pceConstraints.getExcludeClliNodes().size());
64         List<String> nodes = new ArrayList<>();
65         nodes.add("test");
66         this.pceConstraints.setExcludeClliNodes(nodes);
67         Assert.assertEquals(1, this.pceConstraints.getExcludeClliNodes().size());
68     }
69
70     @Test
71     public void setAndGetExcludeSrlgLinksTest() {
72         Assert.assertEquals(0, this.pceConstraints.getExcludeSrlgLinks().size());
73         List<String> nodes = new ArrayList<>();
74         nodes.add("test");
75         this.pceConstraints.setExcludeSrlgLinks(nodes);
76         Assert.assertEquals(1, this.pceConstraints.getExcludeSrlgLinks().size());
77     }
78
79     @Test
80     public void setAndGetExcludeNodesTest() {
81         Assert.assertEquals(0, this.pceConstraints.getExcludeNodes().size());
82         List<String> nodes = new ArrayList<>();
83         nodes.add("test");
84         this.pceConstraints.setExcludeNodes(nodes);
85         Assert.assertEquals(1, this.pceConstraints.getExcludeNodes().size());
86     }
87
88     @Test
89     public void setAndGetIncludeNodesTest() {
90         Assert.assertEquals(0, this.pceConstraints.getIncludeNodes().size());
91         List<String> nodes = new ArrayList<>();
92         nodes.add("test");
93         this.pceConstraints.setIncludeNodes(nodes);
94         Assert.assertEquals(1, this.pceConstraints.getIncludeNodes().size());
95     }
96
97     @Test
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());
103
104     }
105
106
107     @Test
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);
112
113     }
114
115     @Test
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);
123
124     }
125
126 }
127
128