Open Kilda Java Documentation
InstallEgressFlowTest.java
Go to the documentation of this file.
1 /* Copyright 2017 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.messaging.command.flow;
17 
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertFalse;
27 import static org.junit.Assert.assertNotNull;
28 
30 
31 import org.junit.Test;
32 
33 public class InstallEgressFlowTest {
34  private InstallEgressFlow flow = new InstallEgressFlow(0L, flowName, 0L, switchId, inputPort,
35  outputPort, transitVlanId, outputVlanId, outputVlanType);
36 
37  @Test
38  public void toStringTest() throws Exception {
39  String flowString = flow.toString();
40  assertNotNull(flowString);
41  assertFalse(flowString.isEmpty());
42  }
43 
44  @Test
45  public void getOutputVlanType() throws Exception {
46  assertEquals(outputVlanType, flow.getOutputVlanType());
47  }
48 
49  @Test
50  public void getOutputVlanId() throws Exception {
51  assertEquals(outputVlanId, flow.getOutputVlanId().intValue());
52  }
53 
54  @Test
55  public void setOutputVlanType() throws Exception {
56  flow.setOutputVlanId(outputVlanId);
57  flow.setOutputVlanType(outputVlanType);
58  assertEquals(outputVlanType, flow.getOutputVlanType());
59  }
60 
61  @Test(expected = IllegalArgumentException.class)
62  public void setNullOutputVlanType() throws Exception {
63  flow.setOutputVlanType(null);
64  }
65 
66  @Test(expected = IllegalArgumentException.class)
67  public void setInvalidOutputVlanType() throws Exception {
68  flow.setOutputVlanType(null);
69  }
70 
71  @Test(expected = IllegalArgumentException.class)
72  public void setIncorrectNoneOutputVlanType() throws Exception {
73  flow.setOutputVlanId(outputVlanId);
75  }
76 
77  @Test(expected = IllegalArgumentException.class)
78  public void setIncorrectPopOutputVlanType() throws Exception {
79  flow.setOutputVlanId(outputVlanId);
81  }
82 
83  @Test(expected = IllegalArgumentException.class)
84  public void setIncorrectPushOutputVlanType() throws Exception {
85  flow.setOutputVlanId(0);
87  }
88 
89  @Test(expected = IllegalArgumentException.class)
90  public void setIncorrectReplaceOutputVlanType() throws Exception {
91  flow.setOutputVlanId(null);
93  }
94 
95  @Test
96  public void setOutputVlanId() throws Exception {
97  flow.setOutputVlanId(outputVlanId);
98  assertEquals(outputVlanId, flow.getOutputVlanId().intValue());
99  }
100 
101  @Test
102  public void setNullOutputVlanId() throws Exception {
103  flow.setOutputVlanId(null);
104  assertEquals(0, flow.getOutputVlanId().intValue());
105  }
106 
107  @Test
108  public void setZeroOutputVlanId() throws Exception {
109  flow.setOutputVlanId(0);
110  assertEquals(0, flow.getOutputVlanId().intValue());
111  }
112 
113  @Test(expected = IllegalArgumentException.class)
114  public void setNegativeOutputVlanId() throws Exception {
115  flow.setOutputVlanId(-1);
116  }
117 
118  @Test(expected = IllegalArgumentException.class)
119  public void setTooBigOutputVlanId() throws Exception {
120  flow.setOutputVlanId(4096);
121  }
122 }
void setOutputVlanType(final OutputVlanType outputVlanType)
static final OutputVlanType outputVlanType
Definition: Constants.java:32