Open Kilda Java Documentation
InstallIngressFlowTest.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 
27 import static org.junit.Assert.assertEquals;
28 import static org.junit.Assert.assertFalse;
29 import static org.junit.Assert.assertNotNull;
30 
31 import org.junit.Test;
32 
33 public class InstallIngressFlowTest {
34  private InstallIngressFlow flow = new InstallIngressFlow(0L, flowName, 0L, switchId, inputPort,
35  outputPort, inputVlanId, transitVlanId, outputVlanType, bandwidth, meterId);
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 getBandwidth() throws Exception {
46  assertEquals(bandwidth, flow.getBandwidth().longValue());
47  }
48 
49  @Test
50  public void getMeterId() throws Exception {
51  assertEquals(meterId, flow.getMeterId().longValue());
52  }
53 
54  @Test
55  public void getInputVlanId() throws Exception {
56  assertEquals(inputVlanId, flow.getInputVlanId().intValue());
57  }
58 
59  @Test
60  public void setBandwidth() throws Exception {
61  flow.setBandwidth(bandwidth);
62  assertEquals(bandwidth, flow.getBandwidth().longValue());
63  }
64 
65  @Test(expected = IllegalArgumentException.class)
66  public void setNullBandwidth() throws Exception {
67  flow.setBandwidth(null);
68  }
69 
70  @Test(expected = IllegalArgumentException.class)
71  public void setNegativeBandwidth() throws Exception {
72  flow.setBandwidth(-1L);
73  }
74 
75  @Test
76  public void setMeterId() throws Exception {
77  flow.setMeterId(meterId);
78  assertEquals(meterId, flow.getMeterId().longValue());
79  }
80 
81  @Test(expected = IllegalArgumentException.class)
82  public void setNullMeterId() throws Exception {
83  flow.setMeterId(null);
84  }
85 
86  @Test(expected = IllegalArgumentException.class)
87  public void setNegativeMeterId() throws Exception {
88  flow.setMeterId(-1L);
89  }
90 
91  @Test
92  public void setInputVlanId() throws Exception {
93  flow.setInputVlanId(inputVlanId);
94  assertEquals(inputVlanId, flow.getInputVlanId().intValue());
95  }
96 
97  @Test
98  public void setNullInputVlanId() throws Exception {
99  flow.setInputVlanId(null);
100  assertEquals(0, flow.getInputVlanId().intValue());
101  }
102 
103  @Test
104  public void setZeroInputVlanId() throws Exception {
105  flow.setInputVlanId(0);
106  assertEquals(0, flow.getInputVlanId().intValue());
107  }
108 
109  @Test(expected = IllegalArgumentException.class)
110  public void setNegativeInputVlanId() throws Exception {
111  flow.setInputVlanId(-1);
112  }
113 
114  @Test(expected = IllegalArgumentException.class)
115  public void setTooBigInputVlanId() throws Exception {
116  flow.setInputVlanId(4096);
117  }
118 }
static final OutputVlanType outputVlanType
Definition: Constants.java:32