Open Kilda Java Documentation
BaseInstallFlowTest.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 
18 import static org.junit.Assert.assertEquals;
23 
25 
26 import org.junit.Test;
27 
28 public class BaseInstallFlowTest {
29  private static BaseInstallFlow flow = new BaseInstallFlow(0L, flowName, 0L, switchId, inputPort, outputPort);
30 
31  @Test
32  public void getFlowName() throws Exception {
33  assertEquals(flowName, flow.getId());
34  }
35 
36  @Test
37  public void getSwitchId() throws Exception {
38  assertEquals(switchId, flow.getSwitchId());
39  }
40 
41  @Test
42  public void getInputPort() throws Exception {
43  assertEquals(inputPort, flow.getInputPort().intValue());
44  }
45 
46  @Test
47  public void getOutputPort() throws Exception {
48  assertEquals(outputPort, flow.getOutputPort().intValue());
49  }
50 
51  @Test
52  public void setFlowName() throws Exception {
53  flow.setId(flowName);
54  assertEquals(flowName, flow.getId());
55  }
56 
57  @Test
58  public void setSwitchId() throws Exception {
59  flow.setSwitchId(switchId);
60  assertEquals(switchId, flow.getSwitchId());
61  }
62 
63  @Test
64  public void setInputPort() throws Exception {
65  flow.setInputPort(inputPort);
66  assertEquals(inputPort, flow.getInputPort().intValue());
67  }
68 
69  @Test
70  public void setOutputPort() throws Exception {
71  flow.setOutputPort(outputPort);
72  assertEquals(outputPort, flow.getOutputPort().intValue());
73  }
74 
75  @Test(expected = IllegalArgumentException.class)
76  public void setNullFlowName() throws Exception {
77  flow.setId(null);
78  }
79 
80  @Test(expected = IllegalArgumentException.class)
81  public void setNullSwitchId() throws Exception {
82  flow.setSwitchId(null);
83  }
84 
85  @Test(expected = IllegalArgumentException.class)
86  public void setIncorrectSwitchId() throws Exception {
87  flow.setSwitchId(new SwitchId(""));
88  }
89 
90  @Test(expected = IllegalArgumentException.class)
91  public void setNullInputPort() throws Exception {
92  flow.setInputPort(null);
93  }
94 
95  @Test(expected = IllegalArgumentException.class)
96  public void setNullOutputPort() throws Exception {
97  flow.setOutputPort(null);
98  }
99 
100  @Test(expected = IllegalArgumentException.class)
101  public void setNegativeInputPort() throws Exception {
102  flow.setInputPort(-1);
103  }
104 
105  @Test(expected = IllegalArgumentException.class)
106  public void setNegativeOutputPort() throws Exception {
107  flow.setOutputPort(-1);
108  }
109 }