ilhem fajjari
Committed by Gerrit Code Review

add key parameter to PathIntent and MplsPathIntent constructors

Change-Id: I157c1e3e10dc3e3ebc1dbc6f9a1c9fe769337ee3
......@@ -42,6 +42,7 @@ public final class MplsPathIntent extends PathIntent {
* 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 @@ public final class MplsPathIntent extends PathIntent {
* @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 @@ public final class MplsPathIntent extends PathIntent {
return new MplsPathIntent(
appId,
key,
selector,
treatment,
path,
......
......@@ -42,6 +42,7 @@ public class PathIntent extends ConnectivityIntent {
* 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 @@ public class PathIntent extends ConnectivityIntent {
* @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 @@ public class PathIntent extends ConnectivityIntent {
return new PathIntent(
appId,
key,
selector,
treatment,
path,
......@@ -184,6 +187,7 @@ public class PathIntent extends ConnectivityIntent {
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("id", id())
.add("key", key())
.add("appId", appId())
.add("priority", priority())
.add("resources", resources())
......
......@@ -33,6 +33,7 @@ import org.onosproject.net.flow.TrafficTreatment;
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();
......
......@@ -112,6 +112,5 @@ public class MplsIntentTest extends AbstractIntentTest {
assertThat(intent1.selector(), equalTo(intent2.selector()));
assertThat(intent1.treatment(), equalTo(intent2.treatment()));
assertThat(intent1.priority(), is(PRIORITY));
}
}
......
......@@ -47,6 +47,7 @@ public class MplsPathIntentTest extends AbstractIntentTest {
Optional<MplsLabel> label2;
TrafficSelector selector;
TrafficTreatment treatment;
static final Key KEY1 = Key.of(5L, APP_ID);
@Before
public void mplsPathIntentTestSetUp() {
......@@ -58,6 +59,7 @@ public class MplsPathIntentTest extends AbstractIntentTest {
label2 = Optional.of(MplsLabel.mplsLabel(2));
intent1 = MplsPathIntent.builder()
.appId(APP_ID)
.key(KEY1)
.ingressLabel(label1)
.egressLabel(label2)
.path(defaultPath)
......@@ -105,6 +107,7 @@ public class MplsPathIntentTest extends AbstractIntentTest {
assertThat(intent1.treatment(), equalTo(intent2.treatment()));
assertThat(intent1.priority(), is(PRIORITY));
assertThat(intent1.path(), is(defaultPath));
assertThat(intent1.key(), equalTo(KEY1));
}
}
......
......@@ -62,12 +62,14 @@ public class PathIntentTest extends ConnectivityIntentTest {
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)
......
......@@ -63,6 +63,7 @@ public class PropertyPanelTest {
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";
......