Remove deprecated instructions() method in the traffic treatment class
Change-Id: I739b35bdcbf9867c639c7b6ca4006f3eeafbb055
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
index 5b2343e..da3cac6 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
@@ -32,6 +32,8 @@
import java.util.List;
import java.util.Objects;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* Default traffic treatment implementation.
*/
@@ -52,7 +54,7 @@
* @param instructions treatment instructions
*/
private DefaultTrafficTreatment(List<Instruction> instructions) {
- this.immediate = ImmutableList.copyOf(instructions);
+ this.immediate = ImmutableList.copyOf(checkNotNull(instructions));
this.deferred = ImmutableList.of();
this.hasClear = false;
this.table = null;
@@ -62,19 +64,14 @@
List<Instruction> immediate,
Instructions.TableTypeTransition table,
boolean clear) {
- this.immediate = ImmutableList.copyOf(immediate);
- this.deferred = ImmutableList.copyOf(deferred);
+ this.immediate = ImmutableList.copyOf(checkNotNull(immediate));
+ this.deferred = ImmutableList.copyOf(checkNotNull(deferred));
this.table = table;
this.hasClear = clear;
}
@Override
- public List<Instruction> instructions() {
- return immediate;
- }
-
- @Override
public List<Instruction> deferred() {
return deferred;
}
@@ -184,7 +181,7 @@
// Creates a new builder based off an existing treatment
//FIXME only works for immediate instruction sets.
private Builder(TrafficTreatment treatment) {
- for (Instruction instruction : treatment.instructions()) {
+ for (Instruction instruction : treatment.immediate()) {
add(instruction);
}
}
diff --git a/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
index 0732e35..a2254fa 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
@@ -32,14 +32,6 @@
public interface TrafficTreatment {
/**
- * Returns list of instructions on how to treat traffic.
- *
- * @return list of treatment instructions
- */
- @Deprecated
- List<Instruction> instructions();
-
- /**
* Returns the list of treatment instructions that will be applied
* further down the pipeline.
* @return list of treatment instructions
diff --git a/core/api/src/main/java/org/onosproject/net/flowext/DefaultFlowRuleExt.java b/core/api/src/main/java/org/onosproject/net/flowext/DefaultFlowRuleExt.java
index 721cced..c72d4db 100644
--- a/core/api/src/main/java/org/onosproject/net/flowext/DefaultFlowRuleExt.java
+++ b/core/api/src/main/java/org/onosproject/net/flowext/DefaultFlowRuleExt.java
@@ -102,7 +102,7 @@
.add("deviceId", deviceId())
.add("priority", priority())
.add("selector", selector().criteria())
- .add("treatment", treatment() == null ? "N/A" : treatment().instructions())
+ .add("treatment", treatment() == null ? "N/A" : treatment().allInstructions())
//.add("created", created)
.add("flowEntryExtension", flowEntryExtension)
.toString();
diff --git a/core/api/src/main/java/org/onosproject/net/group/DefaultGroupBucket.java b/core/api/src/main/java/org/onosproject/net/group/DefaultGroupBucket.java
index ff1271e..e4910d5 100644
--- a/core/api/src/main/java/org/onosproject/net/group/DefaultGroupBucket.java
+++ b/core/api/src/main/java/org/onosproject/net/group/DefaultGroupBucket.java
@@ -15,15 +15,17 @@
*/
package org.onosproject.net.group;
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
import org.onosproject.core.GroupId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.flow.instructions.Instruction;
+
+import java.util.List;
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
/**
* Group bucket implementation. A group bucket is collection of
@@ -206,9 +208,12 @@
}
if (obj instanceof DefaultGroupBucket) {
DefaultGroupBucket that = (DefaultGroupBucket) obj;
+ List<Instruction> myInstructions = this.treatment.allInstructions();
+ List<Instruction> theirInstructions = that.treatment.allInstructions();
+
return Objects.equals(type, that.type) &&
- this.treatment.instructions().containsAll(that.treatment.instructions()) &&
- that.treatment.instructions().containsAll(this.treatment.instructions());
+ myInstructions.containsAll(theirInstructions) &&
+ theirInstructions.containsAll(myInstructions);
}
return false;
}
diff --git a/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficTreatmentTest.java b/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficTreatmentTest.java
index 1086585..ad04602 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficTreatmentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficTreatmentTest.java
@@ -75,14 +75,24 @@
final TrafficTreatment treatment1 = builder1.build();
- final List<Instruction> instructions1 = treatment1.instructions();
+ final List<Instruction> instructions1 = treatment1.immediate();
assertThat(instructions1, hasSize(9));
builder1.drop();
builder1.add(instruction1);
- final List<Instruction> instructions2 = builder1.build().instructions();
+ final List<Instruction> instructions2 = builder1.build().immediate();
assertThat(instructions2, hasSize(11));
+
+ builder1.deferred()
+ .popVlan()
+ .pushVlan()
+ .setVlanId(VlanId.vlanId((short) 5));
+
+ final List<Instruction> instructions3 = builder1.build().immediate();
+ assertThat(instructions3, hasSize(11));
+ final List<Instruction> instructions4 = builder1.build().deferred();
+ assertThat(instructions4, hasSize(3));
}
/**
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 4ae09fb..14abd83 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
@@ -93,18 +93,13 @@
*/
public static class MockTreatment implements TrafficTreatment {
@Override
- public List<Instruction> instructions() {
- return new ArrayList<>();
- }
-
- @Override
public List<Instruction> deferred() {
return null;
}
@Override
public List<Instruction> immediate() {
- return null;
+ return new ArrayList<>();
}
@Override