Add unit tests for ModL0OchSignalInstruction
Resolve ONOS-1876 Change-Id: Ideca55e2d5ebb15478577d390e1a71761d672d7e
Showing
1 changed file
with
39 additions
and
1 deletions
| ... | @@ -16,6 +16,9 @@ | ... | @@ -16,6 +16,9 @@ |
| 16 | package org.onosproject.net.flow.instructions; | 16 | package org.onosproject.net.flow.instructions; |
| 17 | 17 | ||
| 18 | import org.junit.Test; | 18 | import org.junit.Test; |
| 19 | +import org.onosproject.net.ChannelSpacing; | ||
| 20 | +import org.onosproject.net.GridType; | ||
| 21 | +import org.onosproject.net.Lambda; | ||
| 19 | import org.onosproject.net.PortNumber; | 22 | import org.onosproject.net.PortNumber; |
| 20 | import org.onlab.packet.IpAddress; | 23 | import org.onlab.packet.IpAddress; |
| 21 | import org.onlab.packet.MacAddress; | 24 | import org.onlab.packet.MacAddress; |
| ... | @@ -90,6 +93,7 @@ public class InstructionsTest { | ... | @@ -90,6 +93,7 @@ public class InstructionsTest { |
| 90 | assertThatClassIsImmutable(Instructions.DropInstruction.class); | 93 | assertThatClassIsImmutable(Instructions.DropInstruction.class); |
| 91 | assertThatClassIsImmutable(Instructions.OutputInstruction.class); | 94 | assertThatClassIsImmutable(Instructions.OutputInstruction.class); |
| 92 | assertThatClassIsImmutable(L0ModificationInstruction.ModLambdaInstruction.class); | 95 | assertThatClassIsImmutable(L0ModificationInstruction.ModLambdaInstruction.class); |
| 96 | + assertThatClassIsImmutable(L0ModificationInstruction.ModOchSignalInstruction.class); | ||
| 93 | assertThatClassIsImmutable(L2ModificationInstruction.ModEtherInstruction.class); | 97 | assertThatClassIsImmutable(L2ModificationInstruction.ModEtherInstruction.class); |
| 94 | assertThatClassIsImmutable(L2ModificationInstruction.ModVlanIdInstruction.class); | 98 | assertThatClassIsImmutable(L2ModificationInstruction.ModVlanIdInstruction.class); |
| 95 | assertThatClassIsImmutable(L2ModificationInstruction.ModVlanPcpInstruction.class); | 99 | assertThatClassIsImmutable(L2ModificationInstruction.ModVlanPcpInstruction.class); |
| ... | @@ -195,7 +199,6 @@ public class InstructionsTest { | ... | @@ -195,7 +199,6 @@ public class InstructionsTest { |
| 195 | assertThat(lambdaInstruction.lambda(), is(equalTo(lambda1))); | 199 | assertThat(lambdaInstruction.lambda(), is(equalTo(lambda1))); |
| 196 | } | 200 | } |
| 197 | 201 | ||
| 198 | - | ||
| 199 | /** | 202 | /** |
| 200 | * Test the equals() method of the ModLambdaInstruction class. | 203 | * Test the equals() method of the ModLambdaInstruction class. |
| 201 | */ | 204 | */ |
| ... | @@ -219,6 +222,41 @@ public class InstructionsTest { | ... | @@ -219,6 +222,41 @@ public class InstructionsTest { |
| 219 | is(not(equalTo(lambdaInstruction2.hashCode())))); | 222 | is(not(equalTo(lambdaInstruction2.hashCode())))); |
| 220 | } | 223 | } |
| 221 | 224 | ||
| 225 | + private final Lambda och1 = Lambda.ochSignal(GridType.DWDM, ChannelSpacing.CHL_100GHZ, 4, 8); | ||
| 226 | + private final Lambda och2 = Lambda.ochSignal(GridType.CWDM, ChannelSpacing.CHL_100GHZ, 4, 8); | ||
| 227 | + private final Instruction ochInstruction1 = Instructions.modL0Lambda(och1); | ||
| 228 | + private final Instruction sameAsOchInstruction1 = Instructions.modL0Lambda(och1); | ||
| 229 | + private final Instruction ochInstruction2 = Instructions.modL0Lambda(och2); | ||
| 230 | + | ||
| 231 | + /** | ||
| 232 | + * Test the modL0Lambda(). | ||
| 233 | + */ | ||
| 234 | + @Test | ||
| 235 | + public void testModL0LambdaMethod() { | ||
| 236 | + Instruction instruction = Instructions.modL0Lambda(och1); | ||
| 237 | + L0ModificationInstruction.ModOchSignalInstruction ochInstruction = | ||
| 238 | + checkAndConvert(instruction, Instruction.Type.L0MODIFICATION, | ||
| 239 | + L0ModificationInstruction.ModOchSignalInstruction.class); | ||
| 240 | + assertThat(ochInstruction.lambda(), is(och1)); | ||
| 241 | + } | ||
| 242 | + | ||
| 243 | + /** | ||
| 244 | + * Test the equals() method of the ModOchSignalInstruction class. | ||
| 245 | + */ | ||
| 246 | + @Test | ||
| 247 | + public void testModOchSignalInstructionEquals() { | ||
| 248 | + checkEqualsAndToString(ochInstruction1, sameAsOchInstruction1, ochInstruction2); | ||
| 249 | + } | ||
| 250 | + | ||
| 251 | + /** | ||
| 252 | + * Test the hashCode() method of the ModOchSignalInstruction class. | ||
| 253 | + */ | ||
| 254 | + @Test | ||
| 255 | + public void testModOchSignalInstructionHashCode() { | ||
| 256 | + assertThat(ochInstruction1.hashCode(), is(sameAsOchInstruction1.hashCode())); | ||
| 257 | + assertThat(ochInstruction1.hashCode(), is(not(ochInstruction2.hashCode()))); | ||
| 258 | + } | ||
| 259 | + | ||
| 222 | // ModEtherInstruction | 260 | // ModEtherInstruction |
| 223 | 261 | ||
| 224 | private static final String MAC1 = "00:00:00:00:00:01"; | 262 | private static final String MAC1 = "00:00:00:00:00:01"; | ... | ... |
-
Please register or login to post a comment