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