add key parameter to PathIntent and MplsPathIntent constructors
Change-Id: I157c1e3e10dc3e3ebc1dbc6f9a1c9fe769337ee3
diff --git a/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java b/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java
index caa5fbb..4548c44 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java
@@ -42,6 +42,7 @@
* ports and using the specified explicit path.
*
* @param appId application identifier
+ * @param key intent key
* @param selector traffic selector
* @param treatment treatment
* @param path traversed links
@@ -51,11 +52,11 @@
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException {@code path} is null
*/
- private MplsPathIntent(ApplicationId appId, TrafficSelector selector,
+ private MplsPathIntent(ApplicationId appId, Key key, TrafficSelector selector,
TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel,
Optional<MplsLabel> egressLabel, List<Constraint> constraints,
int priority) {
- super(appId, selector, treatment, path, constraints,
+ super(appId, key, selector, treatment, path, constraints,
priority);
this.ingressLabel = checkNotNull(ingressLabel);
@@ -149,6 +150,7 @@
return new MplsPathIntent(
appId,
+ key,
selector,
treatment,
path,
diff --git a/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java b/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
index 0c831fd..9bf137a 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
@@ -42,6 +42,7 @@
* ports and using the specified explicit path.
*
* @param appId application identifier
+ * @param key intent key
* @param selector traffic selector
* @param treatment treatment
* @param path traversed links
@@ -50,12 +51,13 @@
* @throws NullPointerException {@code path} is null
*/
protected PathIntent(ApplicationId appId,
+ Key key,
TrafficSelector selector,
TrafficTreatment treatment,
Path path,
List<Constraint> constraints,
int priority) {
- super(appId, null, resources(path.links()), selector, treatment, constraints,
+ super(appId, key, resources(path.links()), selector, treatment, constraints,
priority);
PathIntent.validate(path.links());
this.path = path;
@@ -138,6 +140,7 @@
return new PathIntent(
appId,
+ key,
selector,
treatment,
path,
@@ -184,6 +187,7 @@
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("id", id())
+ .add("key", key())
.add("appId", appId())
.add("priority", priority())
.add("resources", resources())
diff --git a/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java
index e03ed85..c510b60 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java
@@ -33,6 +33,7 @@
public abstract class ConnectivityIntentTest extends IntentTest {
public static final ApplicationId APPID = new TestApplicationId("foo");
+ public static final Key KEY = Key.of(1L, APPID);
public static final IntentId IID = new IntentId(123);
public static final TrafficSelector MATCH = DefaultTrafficSelector.emptySelector();
diff --git a/core/api/src/test/java/org/onosproject/net/intent/MplsIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/MplsIntentTest.java
index 196d6ad..7fbdf23 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/MplsIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/MplsIntentTest.java
@@ -112,6 +112,5 @@
assertThat(intent1.selector(), equalTo(intent2.selector()));
assertThat(intent1.treatment(), equalTo(intent2.treatment()));
assertThat(intent1.priority(), is(PRIORITY));
-
}
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/MplsPathIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/MplsPathIntentTest.java
index 551f19e..64528cb 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/MplsPathIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/MplsPathIntentTest.java
@@ -47,6 +47,7 @@
Optional<MplsLabel> label2;
TrafficSelector selector;
TrafficTreatment treatment;
+ static final Key KEY1 = Key.of(5L, APP_ID);
@Before
public void mplsPathIntentTestSetUp() {
@@ -58,6 +59,7 @@
label2 = Optional.of(MplsLabel.mplsLabel(2));
intent1 = MplsPathIntent.builder()
.appId(APP_ID)
+ .key(KEY1)
.ingressLabel(label1)
.egressLabel(label2)
.path(defaultPath)
@@ -105,6 +107,7 @@
assertThat(intent1.treatment(), equalTo(intent2.treatment()));
assertThat(intent1.priority(), is(PRIORITY));
assertThat(intent1.path(), is(defaultPath));
+ assertThat(intent1.key(), equalTo(KEY1));
}
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java
index dfbc184..9e67534 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java
@@ -62,12 +62,14 @@
assertEquals("incorrect match", MATCH, intent.selector());
assertEquals("incorrect action", NOP, intent.treatment());
assertEquals("incorrect path", PATH1, intent.path());
+ assertEquals("incorrect key", KEY, intent.key());
}
@Override
protected PathIntent createOne() {
return PathIntent.builder()
.appId(APPID)
+ .key(KEY)
.selector(MATCH)
.treatment(NOP)
.path(PATH1)
diff --git a/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java b/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java
index 157cdc7..b6d32be 100644
--- a/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java
+++ b/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java
@@ -63,6 +63,7 @@
private static final String KEY_C = "C";
private static final String SEP = "-";
private static final String KEY_Z = "Z";
+
private static final String VALUE_A = "Hay";
private static final String VALUE_B = "Bee";
private static final String VALUE_C = "Sea";
@@ -155,8 +156,8 @@
public void props() {
basic();
pp.addProp(KEY_A, VALUE_A)
- .addProp(KEY_B, VALUE_B)
- .addProp(KEY_C, VALUE_C);
+ .addProp(KEY_B, VALUE_B)
+ .addProp(KEY_C, VALUE_C);
assertEquals("bad props", 3, pp.properties().size());
validateProps(KEY_A, KEY_B, KEY_C);
}
@@ -165,7 +166,7 @@
public void separator() {
props();
pp.addSeparator()
- .addProp(KEY_Z, VALUE_Z);
+ .addProp(KEY_Z, VALUE_Z);
assertEquals("bad props", 5, pp.properties().size());
validateProps(KEY_A, KEY_B, KEY_C, SEP, KEY_Z);
@@ -191,8 +192,8 @@
public void intValues() {
basic();
pp.addProp(KEY_A, 200)
- .addProp(KEY_B, 2000)
- .addProp(KEY_C, 1234567);
+ .addProp(KEY_B, 2000)
+ .addProp(KEY_C, 1234567);
validateProp(KEY_A, "200");
validateProp(KEY_B, "2,000");
@@ -203,9 +204,9 @@
public void longValues() {
basic();
pp.addProp(KEY_A, 200L)
- .addProp(KEY_B, 2000L)
- .addProp(KEY_C, 1234567L)
- .addProp(KEY_Z, Long.MAX_VALUE);
+ .addProp(KEY_B, 2000L)
+ .addProp(KEY_C, 1234567L)
+ .addProp(KEY_Z, Long.MAX_VALUE);
validateProp(KEY_A, "200");
validateProp(KEY_B, "2,000");
@@ -217,7 +218,7 @@
public void objectValue() {
basic();
pp.addProp(KEY_A, new FooClass("a"))
- .addProp(KEY_B, new FooClass("bxyyzy"), "[xz]");
+ .addProp(KEY_B, new FooClass("bxyyzy"), "[xz]");
validateProp(KEY_A, ">a<");
validateProp(KEY_B, ">byyy<");