Inherit Intent Key on compilation
- Added Intent#key() method description
- Inherit key field from parent Intent during Intent
compilation process
- Added assertion to existing unit tests
Change-Id: Iff85c5ec448b3f378957b7a20af865ad96cc3216
diff --git a/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java b/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java
index 810e897..f3d3e43 100644
--- a/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java
+++ b/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java
@@ -78,11 +78,13 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.stream.Collectors;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.everyItem;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
@@ -309,6 +311,10 @@
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(1));
+ assertThat("key is inherited",
+ compiled.stream().map(Intent::key).collect(Collectors.toList()),
+ everyItem(is(intent.key())));
+
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
// 1st Device
@@ -395,6 +401,10 @@
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(1));
+ assertThat("key is inherited",
+ compiled.stream().map(Intent::key).collect(Collectors.toList()),
+ everyItem(is(intent.key())));
+
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
// 1st Device