Fixing FlowRule priority in intent compilers

Change-Id: I13998e88d2a116017e87c019f4829101db6c6b6b
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerTest.java
index f314fe9..c5fa371 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerTest.java
@@ -81,7 +81,7 @@
     private LinkCollectionIntentCompiler sut;
 
     @Before
-    public void setUP() {
+    public void setUp() {
         sut = new LinkCollectionIntentCompiler();
         coreService = createMock(CoreService.class);
         expect(coreService.registerApplication("org.onosproject.net.intent"))
@@ -132,6 +132,7 @@
         assertThat(rule1.treatment(), is(
                 DefaultTrafficTreatment.builder(intent.treatment()).setOutput(d1p1.port()).build()
         ));
+        assertThat(rule1.priority(), is(intent.priority()));
 
         FlowRule rule2 = rules.stream()
                 .filter(rule -> rule.deviceId().equals(d2p0.deviceId()))
@@ -143,6 +144,7 @@
         assertThat(rule2.treatment(), is(
                 DefaultTrafficTreatment.builder().setOutput(d2p1.port()).build()
         ));
+        assertThat(rule2.priority(), is(intent.priority()));
 
         FlowRule rule3 = rules.stream()
                 .filter(rule -> rule.deviceId().equals(d3p0.deviceId()))
@@ -154,6 +156,7 @@
         assertThat(rule3.treatment(), is(
                 DefaultTrafficTreatment.builder().setOutput(d3p1.port()).build()
         ));
+        assertThat(rule3.priority(), is(intent.priority()));
 
         sut.deactivate();
     }
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompilerTest.java
index b773f0f..2f40b37 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompilerTest.java
@@ -50,6 +50,7 @@
 import static org.easymock.EasyMock.replay;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.hasSize;
+import static org.junit.Assert.assertEquals;
 import static org.onosproject.net.Link.Type.DIRECT;
 import static org.onosproject.net.NetTestTools.PID;
 import static org.onosproject.net.NetTestTools.connectPoint;
@@ -135,7 +136,12 @@
                 .findFirst()
                 .get();
 
+        rules.forEach(rule -> assertEquals("FlowRule priority is incorrect",
+                                           intent.priority(), rule.priority()));
+
         sut.deactivate();
     }
 
+    //TODO test bidirectional optical paths and verify rules
+
 }
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PathIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PathIntentCompilerTest.java
index 058b607..f07bf42 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PathIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PathIntentCompilerTest.java
@@ -75,6 +75,7 @@
     private final ConnectPoint d3p1 = connectPoint("s3", 1);
     private final ConnectPoint d3p0 = connectPoint("s3", 10);
     private final ConnectPoint d1p0 = connectPoint("s1", 10);
+    private static final int PRIORITY = 555;
 
     private final List<Link> links = Arrays.asList(
             createEdgeLink(d1p0, true),
@@ -102,6 +103,7 @@
                 .appId(APP_ID)
                 .selector(selector)
                 .treatment(treatment)
+                .priority(PRIORITY)
                 .path(new DefaultPath(pid, links, hops))
                 .build();
         intentExtensionService = createMock(IntentExtensionService.class);
@@ -141,6 +143,7 @@
                 is(DefaultTrafficSelector.builder(selector).matchInPort(d1p0.port()).build()));
         assertThat(rule1.treatment(),
                 is(DefaultTrafficTreatment.builder().setOutput(d1p1.port()).build()));
+        assertThat(rule1.priority(), is(intent.priority()));
 
         FlowRule rule2 = rules.stream()
                 .filter(x -> x.deviceId().equals(d2p0.deviceId()))
@@ -151,6 +154,7 @@
                 is(DefaultTrafficSelector.builder(selector).matchInPort(d2p0.port()).build()));
         assertThat(rule2.treatment(),
                 is(DefaultTrafficTreatment.builder().setOutput(d2p1.port()).build()));
+        assertThat(rule2.priority(), is(intent.priority()));
 
         FlowRule rule3 = rules.stream()
                 .filter(x -> x.deviceId().equals(d3p0.deviceId()))
@@ -161,6 +165,7 @@
                 is(DefaultTrafficSelector.builder(selector).matchInPort(d3p1.port()).build()));
         assertThat(rule3.treatment(),
                 is(DefaultTrafficTreatment.builder(treatment).setOutput(d3p0.port()).build()));
+        assertThat(rule3.priority(), is(intent.priority()));
 
         sut.deactivate();
     }