[Cardinal] Add builders for Intents and remove extra constructors.
Starting with PointToPoint intent to see how it looks
Change-Id: I5366a05d657ceaad18c03b95cd71f5d1107200e2
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java
index a879236..63f8ebb 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java
@@ -48,14 +48,25 @@
public List<Intent> compile(TwoWayP2PIntent intent, List<Intent> installable,
Set<LinkResourceAllocations> resources) {
return Lists.newArrayList(
- new PointToPointIntent(intent.appId(), intent.key(),
- intent.selector(), intent.treatment(),
- intent.one(), intent.two(),
- intent.constraints(), intent.priority()),
- new PointToPointIntent(intent.appId(), intent.key(),
- intent.selector(), intent.treatment(),
- intent.two(), intent.one(),
- intent.constraints(), intent.priority()));
-
+ PointToPointIntent.builder()
+ .appId(intent.appId())
+ .key(intent.key())
+ .selector(intent.selector())
+ .treatment(intent.treatment())
+ .ingressPoint(intent.one())
+ .egressPoint(intent.two())
+ .constraints(intent.constraints())
+ .priority(intent.priority())
+ .build(),
+ PointToPointIntent.builder()
+ .appId(intent.appId())
+ .key(intent.key())
+ .selector(intent.selector())
+ .treatment(intent.treatment())
+ .ingressPoint(intent.two())
+ .egressPoint(intent.one())
+ .constraints(intent.constraints())
+ .priority(intent.priority())
+ .build());
}
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
index aedc124..b0a5df8 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
@@ -72,9 +72,13 @@
*/
private PointToPointIntent makeIntent(String ingressIdString,
String egressIdString) {
- return new PointToPointIntent(APPID, selector, treatment,
- connectPoint(ingressIdString, 1),
- connectPoint(egressIdString, 1));
+ return PointToPointIntent.builder()
+ .appId(APPID)
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(connectPoint(ingressIdString, 1))
+ .egressPoint(connectPoint(egressIdString, 1))
+ .build();
}
/**
@@ -87,10 +91,14 @@
*/
private PointToPointIntent makeIntent(String ingressIdString,
String egressIdString, List<Constraint> constraints) {
- return new PointToPointIntent(APPID, selector, treatment,
- connectPoint(ingressIdString, 1),
- connectPoint(egressIdString, 1),
- constraints, Intent.DEFAULT_INTENT_PRIORITY);
+ return PointToPointIntent.builder()
+ .appId(APPID)
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(connectPoint(ingressIdString, 1))
+ .egressPoint(connectPoint(egressIdString, 1))
+ .constraints(constraints)
+ .build();
}
/**
@@ -187,7 +195,13 @@
public void testSameSwitchDifferentPortsIntentCompilation() {
ConnectPoint src = new ConnectPoint(deviceId("1"), portNumber(1));
ConnectPoint dst = new ConnectPoint(deviceId("1"), portNumber(2));
- PointToPointIntent intent = new PointToPointIntent(APP_ID, selector, treatment, src, dst);
+ PointToPointIntent intent = PointToPointIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(src)
+ .egressPoint(dst)
+ .build();
String[] hops = {"1"};
PointToPointIntentCompiler sut = makeCompiler(hops);
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java
index 11a6e6e..d450812 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java
@@ -90,7 +90,13 @@
Intent.bindIdGenerator(idGenerator);
// Intent creation should be placed after binding an ID generator
- input = new PointToPointIntent(appId, selector, treatment, cp1, cp3);
+ input = PointToPointIntent.builder()
+ .appId(appId)
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(cp1)
+ .egressPoint(cp3)
+ .build();
compiled = new PathIntent(appId, selector, treatment, path);
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallCoordinatingTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallCoordinatingTest.java
index cad6768..678bd2d 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallCoordinatingTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallCoordinatingTest.java
@@ -91,7 +91,13 @@
Intent.bindIdGenerator(idGenerator);
// Intent creation should be placed after binding an ID generator
- input = new PointToPointIntent(appId, selector, treatment, cp1, cp3);
+ input = PointToPointIntent.builder()
+ .appId(appId)
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(cp1)
+ .egressPoint(cp3)
+ .build();
compiled = new PathIntent(appId, selector, treatment, path);
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallingTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallingTest.java
index 89c797c..b7d063f 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallingTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallingTest.java
@@ -91,7 +91,13 @@
Intent.bindIdGenerator(idGenerator);
// Intent creation should be placed after binding an ID generator
- input = new PointToPointIntent(appId, selector, treatment, cp1, cp3);
+ input = PointToPointIntent.builder()
+ .appId(appId)
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(cp1)
+ .egressPoint(cp3)
+ .build();
compiled = new PathIntent(appId, selector, treatment, path);
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawCoordinatingTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawCoordinatingTest.java
index f5dbf58..19c3f6f 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawCoordinatingTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawCoordinatingTest.java
@@ -92,7 +92,13 @@
Intent.bindIdGenerator(idGenerator);
// Intent creation should be placed after binding an ID generator
- input = new PointToPointIntent(appId, selector, treatment, cp1, cp3);
+ input = PointToPointIntent.builder()
+ .appId(appId)
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(cp1)
+ .egressPoint(cp3)
+ .build();
compiled = new PathIntent(appId, selector, treatment, path);
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawingTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawingTest.java
index 1861ae5..a1f08ec 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawingTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawingTest.java
@@ -90,7 +90,13 @@
Intent.bindIdGenerator(idGenerator);
// Intent creation should be placed after binding an ID generator
- input = new PointToPointIntent(appId, selector, treatment, cp1, cp3);
+ input = PointToPointIntent.builder()
+ .appId(appId)
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(cp1)
+ .egressPoint(cp3)
+ .build();
compiled = new PathIntent(appId, selector, treatment, path);
}