[ONOS-6017] Implement DefaultMappingKey and DefaultMappingValue
Change-Id: Ie41242436323d9fa89400c2ab661fcc35518b9c8
diff --git a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingEntryTest.java b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingEntryTest.java
index d9b1ff8..47aadbe 100644
--- a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingEntryTest.java
+++ b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingEntryTest.java
@@ -27,8 +27,10 @@
*/
public class DefaultMappingEntryTest {
- private static final MappingKey MAPPING_KEY = new DefaultMappingKey();
- private static final MappingValue MAPPING_VALUE = new DefaultMappingValue();
+ private static final MappingKey MAPPING_KEY =
+ new MappingTestMocks.MockMappingKey();
+ private static final MappingValue MAPPING_VALUE =
+ new MappingTestMocks.MockMappingValue();
/**
* Creates a new mapping entry from an unique value.
diff --git a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingKeyTest.java b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingKeyTest.java
new file mode 100644
index 0000000..35d464b
--- /dev/null
+++ b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingKeyTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.mapping;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onlab.packet.IpPrefix;
+import org.onosproject.mapping.addresses.MappingAddress;
+import org.onosproject.mapping.addresses.MappingAddresses;
+
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * Unit tests for the default mapping key class.
+ */
+public class DefaultMappingKeyTest {
+
+ private static final String IP_ADDRESS_1 = "1.2.3.4/24";
+ private static final String IP_ADDRESS_2 = "5.6.7.8/24";
+
+ /**
+ * Checks that the DefaultMappingKey class is immutable.
+ */
+ @Test
+ public void testImmutability() {
+ assertThatClassIsImmutable(DefaultMappingKey.class);
+ }
+
+ /**
+ * Tests equals() method.
+ */
+ @Test
+ public void testEquals() {
+ IpPrefix ip1 = IpPrefix.valueOf(IP_ADDRESS_1);
+ MappingAddress address1 = MappingAddresses.ipv4MappingAddress(ip1);
+
+ MappingKey key1 = DefaultMappingKey.builder()
+ .withAddress(address1)
+ .build();
+ MappingKey sameAsKey1 = DefaultMappingKey.builder()
+ .withAddress(address1)
+ .build();
+
+ IpPrefix ip2 = IpPrefix.valueOf(IP_ADDRESS_2);
+ MappingAddress address2 = MappingAddresses.ipv4MappingAddress(ip2);
+
+ MappingKey key2 = DefaultMappingKey.builder()
+ .withAddress(address2)
+ .build();
+
+ new EqualsTester()
+ .addEqualityGroup(key1, sameAsKey1)
+ .addEqualityGroup(key2)
+ .testEquals();
+ }
+}
diff --git a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingTest.java b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingTest.java
index 6a87d8b..d2df07b 100644
--- a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingTest.java
+++ b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingTest.java
@@ -38,8 +38,8 @@
Mapping.Builder builder1 = new DefaultMapping.Builder();
DeviceId deviceId1 = DeviceId.deviceId("lisp:10.1.1.1");
- MappingKey mappingKey1 = new DefaultMappingKey();
- MappingValue mappingValue1 = new DefaultMappingValue();
+ MappingKey mappingKey1 = new MappingTestMocks.MockMappingKey();
+ MappingValue mappingValue1 = new MappingTestMocks.MockMappingValue();
mapping1 = builder1
.withId(1)
@@ -62,8 +62,8 @@
mapping2 = builder3
.withId(2)
- .withKey(new DefaultMappingKey())
- .withValue(new DefaultMappingValue())
+ .withKey(new MappingTestMocks.MockMappingKey())
+ .withValue(new MappingTestMocks.MockMappingValue())
.forDevice(deviceId2)
.build();
}
diff --git a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingTreatmentTest.java b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingTreatmentTest.java
new file mode 100644
index 0000000..e3faaa7
--- /dev/null
+++ b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingTreatmentTest.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.mapping;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onlab.packet.IpPrefix;
+import org.onosproject.mapping.addresses.MappingAddress;
+import org.onosproject.mapping.addresses.MappingAddresses;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * Unit tests for the default mapping treatment class.
+ */
+public class DefaultMappingTreatmentTest {
+
+ private static final String IP_ADDRESS_1 = "1.2.3.4/24";
+ private static final String IP_ADDRESS_2 = "5.6.7.8/24";
+
+ /**
+ * Checks that the DefaultMappingTreatment class is immutable.
+ */
+ @Test
+ public void testImmutability() {
+ assertThatClassIsImmutable(DefaultMappingTreatment.class);
+ }
+
+ /**
+ * Tests method defined on the Builder.
+ */
+ @Test
+ public void testBuilderMethods() {
+ IpPrefix ip = IpPrefix.valueOf(IP_ADDRESS_1);
+ MappingAddress address = MappingAddresses.ipv4MappingAddress(ip);
+
+ MappingTreatment.Builder builder =
+ DefaultMappingTreatment.builder()
+ .withAddress(address)
+ .setUnicastPriority(10)
+ .setUnicastWeight(10);
+ MappingTreatment treatment = builder.build();
+ assertThat(treatment.instructions(), hasSize(2));
+ }
+
+ /**
+ * Tests illegal unicast type instruction construction.
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testIllegalUnicastTypeConstruction() {
+ IpPrefix ip = IpPrefix.valueOf(IP_ADDRESS_1);
+ MappingAddress address = MappingAddresses.ipv4MappingAddress(ip);
+
+ DefaultMappingTreatment.builder()
+ .withAddress(address)
+ .setUnicastPriority(10)
+ .setUnicastWeight(10)
+ .setUnicastPriority(20)
+ .build();
+ }
+
+ /**
+ * Tests illegal multicast type instruction construction.
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testIllegalMulticastTypeConstruction() {
+ IpPrefix ip = IpPrefix.valueOf(IP_ADDRESS_1);
+ MappingAddress address = MappingAddresses.ipv4MappingAddress(ip);
+
+ DefaultMappingTreatment.builder()
+ .withAddress(address)
+ .setMulticastPriority(10)
+ .setMulticastWeight(10)
+ .setMulticastPriority(20)
+ .build();
+ }
+
+ /**
+ * Tests equals() method.
+ */
+ @Test
+ public void testEquals() {
+ IpPrefix ip1 = IpPrefix.valueOf(IP_ADDRESS_1);
+ MappingAddress address1 = MappingAddresses.ipv4MappingAddress(ip1);
+
+ MappingTreatment treatment1 = DefaultMappingTreatment.builder()
+ .withAddress(address1)
+ .setUnicastPriority(10)
+ .setUnicastWeight(10)
+ .build();
+
+ MappingTreatment sameAsTreatment1 = DefaultMappingTreatment.builder()
+ .withAddress(address1)
+ .setUnicastPriority(10)
+ .setUnicastWeight(10)
+ .build();
+
+ IpPrefix ip2 = IpPrefix.valueOf(IP_ADDRESS_2);
+ MappingAddress address2 = MappingAddresses.ipv4MappingAddress(ip2);
+
+ MappingTreatment treatment2 = DefaultMappingTreatment.builder()
+ .withAddress(address2)
+ .setMulticastPriority(20)
+ .setMulticastWeight(20)
+ .build();
+
+ new EqualsTester()
+ .addEqualityGroup(treatment1, sameAsTreatment1)
+ .addEqualityGroup(treatment2)
+ .testEquals();
+ }
+}
diff --git a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingValueTest.java b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingValueTest.java
new file mode 100644
index 0000000..6c857d6
--- /dev/null
+++ b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/DefaultMappingValueTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.mapping;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onlab.packet.IpPrefix;
+import org.onosproject.mapping.actions.MappingAction;
+import org.onosproject.mapping.actions.MappingActions;
+import org.onosproject.mapping.addresses.MappingAddress;
+import org.onosproject.mapping.addresses.MappingAddresses;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * Unit tests for the default mapping value class.
+ */
+public class DefaultMappingValueTest {
+
+ private static final String IP_ADDRESS_1 = "1.2.3.4/24";
+ private static final String IP_ADDRESS_2 = "5.6.7.8/24";
+ private final IpPrefix ip1 = IpPrefix.valueOf(IP_ADDRESS_1);
+ private final IpPrefix ip2 = IpPrefix.valueOf(IP_ADDRESS_2);
+ private final MappingAddress ma1 = MappingAddresses.ipv4MappingAddress(ip1);
+ private final MappingAddress ma2 = MappingAddresses.ipv4MappingAddress(ip2);
+
+ /**
+ * Checks that the DefaultMappingValue class is immutable.
+ */
+ @Test
+ public void testImmutability() {
+ assertThatClassIsImmutable(DefaultMappingValue.class);
+ }
+
+ /**
+ * Tests methods defined on the Builder.
+ */
+ @Test
+ public void testBuilderMethods() {
+ MappingAction action = MappingActions.noAction();
+ MappingTreatment treatment = DefaultMappingTreatment.builder()
+ .withAddress(ma1)
+ .setUnicastPriority(10)
+ .setUnicastWeight(10)
+ .build();
+
+ MappingValue value = DefaultMappingValue.builder()
+ .withAction(action)
+ .add(treatment)
+ .build();
+
+ assertThat(value.action(), is(action));
+ assertThat(value.treatments(), hasSize(1));
+ }
+
+ /**
+ * Tests equals() method.
+ */
+ @Test
+ public void testEquals() {
+ MappingTreatment treatment1 = DefaultMappingTreatment.builder()
+ .withAddress(ma1)
+ .setUnicastPriority(10)
+ .setUnicastWeight(10)
+ .build();
+
+ MappingTreatment treatment2 = DefaultMappingTreatment.builder()
+ .withAddress(ma2)
+ .setUnicastPriority(20)
+ .setUnicastWeight(20)
+ .build();
+
+ MappingAction noAction = MappingActions.noAction();
+ MappingAction forward = MappingActions.forward();
+
+ MappingValue value1 = DefaultMappingValue.builder()
+ .withAction(noAction)
+ .add(treatment1)
+ .build();
+
+ MappingValue sameAsValue1 = DefaultMappingValue.builder()
+ .withAction(noAction)
+ .add(treatment1)
+ .build();
+
+ MappingValue value2 = DefaultMappingValue.builder()
+ .withAction(forward)
+ .add(treatment2)
+ .build();
+
+ new EqualsTester()
+ .addEqualityGroup(value1, sameAsValue1)
+ .addEqualityGroup(value2)
+ .testEquals();
+ }
+}
diff --git a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/MappingEventTest.java b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/MappingEventTest.java
index 35a33db..2da8863 100644
--- a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/MappingEventTest.java
+++ b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/MappingEventTest.java
@@ -28,6 +28,9 @@
*/
public class MappingEventTest extends AbstractEventTest {
+ private static final String DEVICE_ID_1 = "lisp:10.1.1.1";
+ private static final String DEVICE_ID_2 = "lisp:10.1.1.2";
+
private MappingEvent event1;
private MappingEvent sameAsEvent1;
private MappingEvent event2;
@@ -45,16 +48,16 @@
return builder
.withId(mid)
- .withKey(new DefaultMappingKey())
- .withValue(new DefaultMappingValue())
+ .withKey(new MappingTestMocks.MockMappingKey())
+ .withValue(new MappingTestMocks.MockMappingValue())
.forDevice(deviceId)
.build();
}
@Before
public void setup() {
- final Mapping mapping1 = mockMapping(1, "lisp:10.1.1.1");
- final Mapping mapping2 = mockMapping(2, "lisp:10.1.1.2");
+ final Mapping mapping1 = mockMapping(1, DEVICE_ID_1);
+ final Mapping mapping2 = mockMapping(2, DEVICE_ID_2);
event1 = new MappingEvent(MappingEvent.Type.MAPPING_ADDED, mapping1);
sameAsEvent1 = new MappingEvent(MappingEvent.Type.MAPPING_ADDED, mapping1);
@@ -79,7 +82,7 @@
@Test
public void testConstructor() {
final long time = System.currentTimeMillis();
- final Mapping mapping = mockMapping(1, "lisp:10.1.1.1");
+ final Mapping mapping = mockMapping(1, DEVICE_ID_1);
final MappingEvent event = new MappingEvent(MappingEvent.Type.MAPPING_UPDATED, mapping);
validateEvent(event, MappingEvent.Type.MAPPING_UPDATED, mapping, time,
time + TimeUnit.SECONDS.toMillis(30));
diff --git a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/MappingTestMocks.java b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/MappingTestMocks.java
new file mode 100644
index 0000000..364a9b0
--- /dev/null
+++ b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/MappingTestMocks.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.mapping;
+
+import org.onlab.packet.IpPrefix;
+import org.onosproject.mapping.actions.MappingAction;
+import org.onosproject.mapping.actions.MappingActions;
+import org.onosproject.mapping.addresses.MappingAddress;
+import org.onosproject.mapping.addresses.MappingAddresses;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Commons mocks used by the mapping management tasks.
+ */
+public class MappingTestMocks {
+
+ private static final String IP = "1.2.3.4/24";
+
+ /**
+ * Mock mapping key class used for satisfying API requirements.
+ */
+ public static class MockMappingKey implements MappingKey {
+
+ @Override
+ public MappingAddress address() {
+ IpPrefix ip = IpPrefix.valueOf(IP);
+ return MappingAddresses.ipv4MappingAddress(ip);
+ }
+ }
+
+ /**
+ * Mock mapping value class used for satisfying API requirements.
+ */
+ public static class MockMappingValue implements MappingValue {
+
+ @Override
+ public MappingAction action() {
+ return MappingActions.noAction();
+ }
+
+ @Override
+ public List<MappingTreatment> treatments() {
+ return Collections.emptyList();
+ }
+ }
+}
diff --git a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/actions/MappingActionsTest.java b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/actions/MappingActionsTest.java
new file mode 100644
index 0000000..68a989f
--- /dev/null
+++ b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/actions/MappingActionsTest.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.mapping.actions;
+
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import static org.onlab.junit.UtilityClassChecker.assertThatClassIsUtility;
+
+/**
+ * Unit tests for various mapping action implementation classes.
+ */
+public class MappingActionsTest {
+
+ /**
+ * Checks that a MappingAction object has the proper type, and then converts
+ * it to the proper type.
+ *
+ * @param action MappingAction object to convert
+ * @param type Enumerated type value for the MappingAction class
+ * @param clazz Desired MappingAction class
+ * @param <T> The type the caller wants returned
+ * @return converted object
+ */
+ @SuppressWarnings("unchecked")
+ private <T> T checkAndConvert(MappingAction action, MappingAction.Type type, Class clazz) {
+ assertThat(action, is(notNullValue()));
+ assertThat(action.type(), is(equalTo(type)));
+ assertThat(action, instanceOf(clazz));
+ return (T) action;
+ }
+
+ /**
+ * Checks that the MappingActions class is a valid utility class.
+ */
+ @Test
+ public void testMappingActionsUtility() {
+ assertThatClassIsUtility(MappingActions.class);
+ }
+
+ /**
+ * Checks that the mapping action implementations are immutable.
+ */
+ @Test
+ public void testMappingActionsImmutability() {
+ assertThatClassIsImmutable(NoMappingAction.class);
+ assertThatClassIsImmutable(ForwardMappingAction.class);
+ assertThatClassIsImmutable(NativeForwardMappingAction.class);
+ assertThatClassIsImmutable(DropMappingAction.class);
+ }
+
+ /**
+ * Tests the noAction method.
+ */
+ @Test
+ public void testNoActionMethod() {
+ MappingAction mappingAction = MappingActions.noAction();
+ checkAndConvert(mappingAction,
+ MappingAction.Type.NO_ACTION,
+ NoMappingAction.class);
+ }
+
+ /**
+ * Tests the forward method.
+ */
+ @Test
+ public void testForwardMethod() {
+ MappingAction mappingAction = MappingActions.forward();
+ checkAndConvert(mappingAction,
+ MappingAction.Type.FORWARD,
+ ForwardMappingAction.class);
+ }
+
+ /**
+ * Tests the native forward method.
+ */
+ @Test
+ public void testNativeForwardMethod() {
+ MappingAction mappingAction = MappingActions.nativeForward();
+ checkAndConvert(mappingAction,
+ MappingAction.Type.NATIVE_FORWARD,
+ NativeForwardMappingAction.class);
+ }
+
+ /**
+ * Tests the drop method.
+ */
+ @Test
+ public void testDropMethod() {
+ MappingAction mappingAction = MappingActions.drop();
+ checkAndConvert(mappingAction,
+ MappingAction.Type.DROP,
+ DropMappingAction.class);
+ }
+}
diff --git a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/instructions/MappingInstructionsTest.java b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/instructions/MappingInstructionsTest.java
index e11022c..59bb3bf 100644
--- a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/instructions/MappingInstructionsTest.java
+++ b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/instructions/MappingInstructionsTest.java
@@ -87,146 +87,12 @@
*/
@Test
public void testImmutabilityOfMappingInstructions() {
- assertThatClassIsImmutable(ActionMappingInstruction.NoActionMappingInstruction.class);
- assertThatClassIsImmutable(ActionMappingInstruction.NativeForwardMappingInstruction.class);
- assertThatClassIsImmutable(ActionMappingInstruction.ForwardMappingInstruction.class);
- assertThatClassIsImmutable(ActionMappingInstruction.DropMappingInstruction.class);
assertThatClassIsImmutable(MulticastMappingInstruction.WeightMappingInstruction.class);
assertThatClassIsImmutable(MulticastMappingInstruction.PriorityMappingInstruction.class);
assertThatClassIsImmutable(UnicastMappingInstruction.WeightMappingInstruction.class);
assertThatClassIsImmutable(UnicastMappingInstruction.PriorityMappingInstruction.class);
}
- private final ActionMappingInstruction noAction1 = MappingInstructions.noAction();
- private final ActionMappingInstruction noAction2 = MappingInstructions.noAction();
-
- /**
- * Tests the noAction method.
- */
- @Test
- public void testNoActionMethod() {
- ActionMappingInstruction instruction = MappingInstructions.noAction();
- checkAndConvert(instruction,
- ActionMappingInstruction.Type.ACTION,
- ActionMappingInstruction.NoActionMappingInstruction.class);
- }
-
- /**
- * Tests the equals() method of the NoActionMappingInstruction class.
- */
- @Test
- public void testNoActionMappingInstructionEquals() {
- new EqualsTester()
- .addEqualityGroup(noAction1, noAction2)
- .testEquals();
- }
-
- /**
- * Tests the hashCode() method of the NoActionMappingInstruction class.
- */
- @Test
- public void testNoActionMappingInstructionHashCode() {
- assertThat(noAction1.hashCode(), is(equalTo(noAction2.hashCode())));
- }
-
- private final ActionMappingInstruction fwdAction1 = MappingInstructions.forwardAction();
- private final ActionMappingInstruction fwdAction2 = MappingInstructions.forwardAction();
-
- /**
- * Tests the forwardAction method.
- */
- @Test
- public void testForwardActionMethod() {
- ActionMappingInstruction instruction = MappingInstructions.forwardAction();
- checkAndConvert(instruction,
- ActionMappingInstruction.Type.ACTION,
- ActionMappingInstruction.ForwardMappingInstruction.class);
- }
-
- /**
- * Tests the equals() method of the ForwardActionMappingInstruction class.
- */
- @Test
- public void testForwardActionMappingInstructionEquals() {
- new EqualsTester()
- .addEqualityGroup(fwdAction1, fwdAction2)
- .testEquals();
- }
-
- /**
- * Tests the hashCode() method of the ForwardActionMappingInstruction class.
- */
- @Test
- public void testForwardActionMappingInstructionHashCode() {
- assertThat(fwdAction1.hashCode(), is(equalTo(fwdAction2.hashCode())));
- }
-
- private final ActionMappingInstruction nativeFwdAction1 =
- MappingInstructions.nativeForwardAction();
- private final ActionMappingInstruction nativeFwdAction2 =
- MappingInstructions.nativeForwardAction();
-
- /**
- * Tests the nativeForwardAction method.
- */
- @Test
- public void testNativeForwardActionMethod() {
- ActionMappingInstruction instruction = MappingInstructions.nativeForwardAction();
- checkAndConvert(instruction,
- ActionMappingInstruction.Type.ACTION,
- ActionMappingInstruction.NativeForwardMappingInstruction.class);
- }
-
- /**
- * Tests the equals() method of the NativeForwardActionMappingInstruction class.
- */
- @Test
- public void testNativeForwardActionMappingInstructionEquals() {
- new EqualsTester()
- .addEqualityGroup(nativeFwdAction1, nativeFwdAction2)
- .testEquals();
- }
-
- /**
- * Tests the hashCode() method of the NativeForwardActionMappingInstruction class.
- */
- @Test
- public void testNativeForwardActionMappingInstructionHashCode() {
- assertThat(nativeFwdAction1.hashCode(), is(equalTo(nativeFwdAction2.hashCode())));
- }
-
- private final ActionMappingInstruction dropAction1 = MappingInstructions.dropAction();
- private final ActionMappingInstruction dropAction2 = MappingInstructions.dropAction();
-
- /**
- * Tests the dropAction method.
- */
- @Test
- public void testDropActionMethod() {
- ActionMappingInstruction instruction = MappingInstructions.dropAction();
- checkAndConvert(instruction,
- ActionMappingInstruction.Type.ACTION,
- ActionMappingInstruction.DropMappingInstruction.class);
- }
-
- /**
- * Tests the equals() method of the DropActionMappingInstruction class.
- */
- @Test
- public void testDropActionMappingInstructionEquals() {
- new EqualsTester()
- .addEqualityGroup(dropAction1, dropAction2)
- .testEquals();
- }
-
- /**
- * Tests the hashCode() method of the DropActionMappingInstruction class.
- */
- @Test
- public void testDropActionMappingInstructionHashCode() {
- assertThat(dropAction1.hashCode(), is(equalTo(dropAction2.hashCode())));
- }
-
private final UnicastMappingInstruction uniWeight1 =
MappingInstructions.unicastWeight(1);
private final UnicastMappingInstruction sameAsUniWeight1 =