Revert "FlowRule equals() incorporates FlowId to factor in treatment."
Using Flow ID forces a dependency on the Group/App ID.
This reverts commit 38f8c232295c33a455887366469f81c874bdef94.
Change-Id: Ib08166c8f778228ebbb68f98c763fcc57a9d6771
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
index cd937f4..e555794 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
@@ -203,8 +203,7 @@
DefaultFlowRule that = (DefaultFlowRule) obj;
return Objects.equals(deviceId, that.deviceId) &&
Objects.equals(priority, that.priority) &&
- Objects.equals(selector, that.selector) &&
- Objects.equals(id, that.id());
+ Objects.equals(selector, that.selector);
}
return false;
diff --git a/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java b/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java
index dcfff60..78c1645 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java
@@ -17,15 +17,12 @@
package org.onosproject.net.flow;
import org.junit.Test;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.intent.IntentTestsMocks;
import com.google.common.testing.EqualsTester;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutableBaseClass;
import static org.onosproject.net.NetTestTools.APP_ID;
import static org.onosproject.net.NetTestTools.did;
@@ -36,12 +33,8 @@
public class DefaultFlowRuleTest {
private static final IntentTestsMocks.MockSelector SELECTOR =
new IntentTestsMocks.MockSelector();
- private static final IntentTestsMocks.MockTreatment TREATMENT1 =
- new IntentTestsMocks.MockTreatment(
- Instructions.createOutput(PortNumber.portNumber(1)));
- private static final IntentTestsMocks.MockTreatment TREATMENT2 =
- new IntentTestsMocks.MockTreatment(
- Instructions.createOutput(PortNumber.portNumber(2)));
+ private static final IntentTestsMocks.MockTreatment TREATMENT =
+ new IntentTestsMocks.MockTreatment();
final FlowRule flowRule1 = new IntentTestsMocks.MockFlowRule(1);
final FlowRule sameAsFlowRule1 = new IntentTestsMocks.MockFlowRule(1);
@@ -92,14 +85,14 @@
public void testCreationWithFlowId() {
final DefaultFlowRule rule =
new DefaultFlowRule(did("1"), SELECTOR,
- TREATMENT1, 22, 33,
+ TREATMENT, 22, 33,
44, false);
assertThat(rule.deviceId(), is(did("1")));
assertThat(rule.id().value(), is(33L));
assertThat(rule.isPermanent(), is(false));
assertThat(rule.priority(), is(22));
assertThat(rule.selector(), is(SELECTOR));
- assertThat(rule.treatment(), is(TREATMENT1));
+ assertThat(rule.treatment(), is(TREATMENT));
assertThat(rule.timeout(), is(44));
}
@@ -110,25 +103,13 @@
public void testCreationWithAppId() {
final DefaultFlowRule rule =
new DefaultFlowRule(did("1"), SELECTOR,
- TREATMENT1, 22, APP_ID,
+ TREATMENT, 22, APP_ID,
44, false);
assertThat(rule.deviceId(), is(did("1")));
assertThat(rule.isPermanent(), is(false));
assertThat(rule.priority(), is(22));
assertThat(rule.selector(), is(SELECTOR));
- assertThat(rule.treatment(), is(TREATMENT1));
+ assertThat(rule.treatment(), is(TREATMENT));
assertThat(rule.timeout(), is(44));
}
-
- /**
- * Tests equality that factors in TrafficTreatment through the flowId.
- */
- @Test
- public void testActionEquals() {
- final DefaultFlowRule rule1 = new DefaultFlowRule(did("1"), SELECTOR,
- TREATMENT1, 22, APP_ID, 44, false);
- final DefaultFlowRule rule2 = new DefaultFlowRule(did("1"), SELECTOR,
- TREATMENT2, 22, APP_ID, 44, false);
- assertThat(rule1, not(rule2));
- }
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
index 4b046e0..6d3605a 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
@@ -80,19 +80,9 @@
* Mock traffic treatment class used for satisfying API requirements.
*/
public static class MockTreatment implements TrafficTreatment {
-
- private List<Instruction> instructions = new ArrayList<>();
-
- public MockTreatment() {
- }
-
- public MockTreatment(Instruction... insts) {
- this.instructions.addAll(Arrays.asList(insts));
- }
-
@Override
public List<Instruction> instructions() {
- return this.instructions;
+ return new ArrayList<>();
}
}