900061989eab56f543503454e7f3c687768cad55
[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
14 import org.junit.Assert;
15 import org.junit.Before;
16 import org.junit.Test;
17
18 import org.opendaylight.transportpce.pce.networkanalyzer.PceOpticalNode;
19 import org.opendaylight.transportpce.test.AbstractTest;
20
21
22
23 public class PceConstraintsTest extends AbstractTest {
24     private static PceConstraints pceConstraints = new PceConstraints();
25
26     @Before
27     public void setup() {
28         pceConstraints = new PceConstraints();
29     }
30
31     @Test
32     public void setAndGetMaxLatencyTest() {
33         Assert.assertEquals(-1, this.pceConstraints.getMaxLatency().intValue());
34         pceConstraints.setMaxLatency(-2L);
35         Assert.assertEquals(-2, this.pceConstraints.getMaxLatency().intValue());
36     }
37
38     @Test
39     public void setAndGetExcludeSupNodesTest() {
40         Assert.assertEquals(0, this.pceConstraints.getExcludeSupNodes().size());
41         List<String> nodes = new ArrayList<>();
42         nodes.add("test");
43         this.pceConstraints.setExcludeSupNodes(nodes);
44         Assert.assertEquals(1, this.pceConstraints.getExcludeSupNodes().size());
45     }
46
47     @Test
48     public void setAndGetExcludeSRLGTest() {
49         Assert.assertEquals(0, this.pceConstraints.getExcludeSRLG().size());
50         List<Long> nodes = new ArrayList<>();
51         nodes.add(1L);
52         this.pceConstraints.setExcludeSRLG(nodes);
53         Assert.assertEquals(1, this.pceConstraints.getExcludeSRLG().size());
54     }
55
56     @Test
57     public void setAndGetExcludeCLLITest() {
58         Assert.assertEquals(0, this.pceConstraints.getExcludeCLLI().size());
59         List<String> nodes = new ArrayList<>();
60         nodes.add("test");
61         this.pceConstraints.setExcludeCLLI(nodes);
62         Assert.assertEquals(1, this.pceConstraints.getExcludeCLLI().size());
63     }
64
65     @Test
66     public void setAndGetExcludeClliNodesTest() {
67         Assert.assertEquals(0, this.pceConstraints.getExcludeClliNodes().size());
68         List<String> nodes = new ArrayList<>();
69         nodes.add("test");
70         this.pceConstraints.setExcludeClliNodes(nodes);
71         Assert.assertEquals(1, this.pceConstraints.getExcludeClliNodes().size());
72     }
73
74     @Test
75     public void setAndGetExcludeSrlgLinksTest() {
76         Assert.assertEquals(0, this.pceConstraints.getExcludeSrlgLinks().size());
77         List<String> nodes = new ArrayList<>();
78         nodes.add("test");
79         this.pceConstraints.setExcludeSrlgLinks(nodes);
80         Assert.assertEquals(1, this.pceConstraints.getExcludeSrlgLinks().size());
81     }
82
83     @Test
84     public void setAndGetExcludeNodesTest() {
85         Assert.assertEquals(0, this.pceConstraints.getExcludeNodes().size());
86         List<String> nodes = new ArrayList<>();
87         nodes.add("test");
88         this.pceConstraints.setExcludeNodes(nodes);
89         Assert.assertEquals(1, this.pceConstraints.getExcludeNodes().size());
90     }
91
92     @Test
93     public void setAndGetIncludeNodesTest() {
94         Assert.assertEquals(0, this.pceConstraints.getIncludeNodes().size());
95         List<String> nodes = new ArrayList<>();
96         nodes.add("test");
97         this.pceConstraints.setIncludeNodes(nodes);
98         Assert.assertEquals(1, this.pceConstraints.getIncludeNodes().size());
99     }
100
101     @Test
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());
107
108     }
109
110
111     @Test
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);
116
117     }
118
119     @Test
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);
127
128     }
129
130 }
131
132