Ayaka Koshibe
Committed by Pavlin Radoslavov

Revert "FlowRule equals() incorporates FlowId to factor in treatment."

Using Flow ID forces a dependency on the Group/App ID.

This reverts commit 38f8c232.

Change-Id: Ib08166c8f778228ebbb68f98c763fcc57a9d6771
...@@ -203,8 +203,7 @@ public class DefaultFlowRule implements FlowRule { ...@@ -203,8 +203,7 @@ public class DefaultFlowRule implements FlowRule {
203 DefaultFlowRule that = (DefaultFlowRule) obj; 203 DefaultFlowRule that = (DefaultFlowRule) obj;
204 return Objects.equals(deviceId, that.deviceId) && 204 return Objects.equals(deviceId, that.deviceId) &&
205 Objects.equals(priority, that.priority) && 205 Objects.equals(priority, that.priority) &&
206 - Objects.equals(selector, that.selector) && 206 + Objects.equals(selector, that.selector);
207 - Objects.equals(id, that.id());
208 207
209 } 208 }
210 return false; 209 return false;
......
...@@ -17,15 +17,12 @@ ...@@ -17,15 +17,12 @@
17 package org.onosproject.net.flow; 17 package org.onosproject.net.flow;
18 18
19 import org.junit.Test; 19 import org.junit.Test;
20 -import org.onosproject.net.PortNumber;
21 -import org.onosproject.net.flow.instructions.Instructions;
22 import org.onosproject.net.intent.IntentTestsMocks; 20 import org.onosproject.net.intent.IntentTestsMocks;
23 21
24 import com.google.common.testing.EqualsTester; 22 import com.google.common.testing.EqualsTester;
25 23
26 import static org.hamcrest.MatcherAssert.assertThat; 24 import static org.hamcrest.MatcherAssert.assertThat;
27 import static org.hamcrest.Matchers.is; 25 import static org.hamcrest.Matchers.is;
28 -import static org.hamcrest.Matchers.not;
29 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutableBaseClass; 26 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutableBaseClass;
30 import static org.onosproject.net.NetTestTools.APP_ID; 27 import static org.onosproject.net.NetTestTools.APP_ID;
31 import static org.onosproject.net.NetTestTools.did; 28 import static org.onosproject.net.NetTestTools.did;
...@@ -36,12 +33,8 @@ import static org.onosproject.net.NetTestTools.did; ...@@ -36,12 +33,8 @@ import static org.onosproject.net.NetTestTools.did;
36 public class DefaultFlowRuleTest { 33 public class DefaultFlowRuleTest {
37 private static final IntentTestsMocks.MockSelector SELECTOR = 34 private static final IntentTestsMocks.MockSelector SELECTOR =
38 new IntentTestsMocks.MockSelector(); 35 new IntentTestsMocks.MockSelector();
39 - private static final IntentTestsMocks.MockTreatment TREATMENT1 = 36 + private static final IntentTestsMocks.MockTreatment TREATMENT =
40 - new IntentTestsMocks.MockTreatment( 37 + new IntentTestsMocks.MockTreatment();
41 - Instructions.createOutput(PortNumber.portNumber(1)));
42 - private static final IntentTestsMocks.MockTreatment TREATMENT2 =
43 - new IntentTestsMocks.MockTreatment(
44 - Instructions.createOutput(PortNumber.portNumber(2)));
45 38
46 final FlowRule flowRule1 = new IntentTestsMocks.MockFlowRule(1); 39 final FlowRule flowRule1 = new IntentTestsMocks.MockFlowRule(1);
47 final FlowRule sameAsFlowRule1 = new IntentTestsMocks.MockFlowRule(1); 40 final FlowRule sameAsFlowRule1 = new IntentTestsMocks.MockFlowRule(1);
...@@ -92,14 +85,14 @@ public class DefaultFlowRuleTest { ...@@ -92,14 +85,14 @@ public class DefaultFlowRuleTest {
92 public void testCreationWithFlowId() { 85 public void testCreationWithFlowId() {
93 final DefaultFlowRule rule = 86 final DefaultFlowRule rule =
94 new DefaultFlowRule(did("1"), SELECTOR, 87 new DefaultFlowRule(did("1"), SELECTOR,
95 - TREATMENT1, 22, 33, 88 + TREATMENT, 22, 33,
96 44, false); 89 44, false);
97 assertThat(rule.deviceId(), is(did("1"))); 90 assertThat(rule.deviceId(), is(did("1")));
98 assertThat(rule.id().value(), is(33L)); 91 assertThat(rule.id().value(), is(33L));
99 assertThat(rule.isPermanent(), is(false)); 92 assertThat(rule.isPermanent(), is(false));
100 assertThat(rule.priority(), is(22)); 93 assertThat(rule.priority(), is(22));
101 assertThat(rule.selector(), is(SELECTOR)); 94 assertThat(rule.selector(), is(SELECTOR));
102 - assertThat(rule.treatment(), is(TREATMENT1)); 95 + assertThat(rule.treatment(), is(TREATMENT));
103 assertThat(rule.timeout(), is(44)); 96 assertThat(rule.timeout(), is(44));
104 } 97 }
105 98
...@@ -110,25 +103,13 @@ public class DefaultFlowRuleTest { ...@@ -110,25 +103,13 @@ public class DefaultFlowRuleTest {
110 public void testCreationWithAppId() { 103 public void testCreationWithAppId() {
111 final DefaultFlowRule rule = 104 final DefaultFlowRule rule =
112 new DefaultFlowRule(did("1"), SELECTOR, 105 new DefaultFlowRule(did("1"), SELECTOR,
113 - TREATMENT1, 22, APP_ID, 106 + TREATMENT, 22, APP_ID,
114 44, false); 107 44, false);
115 assertThat(rule.deviceId(), is(did("1"))); 108 assertThat(rule.deviceId(), is(did("1")));
116 assertThat(rule.isPermanent(), is(false)); 109 assertThat(rule.isPermanent(), is(false));
117 assertThat(rule.priority(), is(22)); 110 assertThat(rule.priority(), is(22));
118 assertThat(rule.selector(), is(SELECTOR)); 111 assertThat(rule.selector(), is(SELECTOR));
119 - assertThat(rule.treatment(), is(TREATMENT1)); 112 + assertThat(rule.treatment(), is(TREATMENT));
120 assertThat(rule.timeout(), is(44)); 113 assertThat(rule.timeout(), is(44));
121 } 114 }
122 -
123 - /**
124 - * Tests equality that factors in TrafficTreatment through the flowId.
125 - */
126 - @Test
127 - public void testActionEquals() {
128 - final DefaultFlowRule rule1 = new DefaultFlowRule(did("1"), SELECTOR,
129 - TREATMENT1, 22, APP_ID, 44, false);
130 - final DefaultFlowRule rule2 = new DefaultFlowRule(did("1"), SELECTOR,
131 - TREATMENT2, 22, APP_ID, 44, false);
132 - assertThat(rule1, not(rule2));
133 - }
134 } 115 }
......
...@@ -80,19 +80,9 @@ public class IntentTestsMocks { ...@@ -80,19 +80,9 @@ public class IntentTestsMocks {
80 * Mock traffic treatment class used for satisfying API requirements. 80 * Mock traffic treatment class used for satisfying API requirements.
81 */ 81 */
82 public static class MockTreatment implements TrafficTreatment { 82 public static class MockTreatment implements TrafficTreatment {
83 -
84 - private List<Instruction> instructions = new ArrayList<>();
85 -
86 - public MockTreatment() {
87 - }
88 -
89 - public MockTreatment(Instruction... insts) {
90 - this.instructions.addAll(Arrays.asList(insts));
91 - }
92 -
93 @Override 83 @Override
94 public List<Instruction> instructions() { 84 public List<Instruction> instructions() {
95 - return this.instructions; 85 + return new ArrayList<>();
96 } 86 }
97 } 87 }
98 88
......