[ONOS-6303] Fix incorrect flow rule from link collection Intent compiler

Change-Id: If39da291c7558cf6a97e742dc0774df0874a9330
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionEncapIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionEncapIntentCompilerTest.java
index 9d83e2c..028f8bf 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionEncapIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionEncapIntentCompilerTest.java
@@ -80,7 +80,7 @@
         sut.registrator = registrator;
         sut.resourceService = new MockResourceService();
 
-        LinkCollectionCompiler.optimize = false;
+        LinkCollectionCompiler.optimizeInstructions = false;
         LinkCollectionCompiler.copyTtl = false;
 
         replay(coreService, intentExtensionService);
@@ -326,7 +326,6 @@
                         .builder()
                         .popMpls(IPV4.ethType())
                         .setOutput(d1p10.port())
-                        .popMpls(IPV4.ethType())
                         .setOutput(d1p11.port())
                         .build()
         ));
@@ -580,8 +579,6 @@
                         .pushMpls()
                         .setMpls(((MplsCriterion) mpls100Selector.getCriterion(MPLS_LABEL)).label())
                         .setOutput(d1p10.port())
-                        .popVlan()
-                        .pushMpls()
                         .setMpls(((MplsCriterion) mpls200Selector.getCriterion(MPLS_LABEL)).label())
                         .setOutput(d1p11.port())
                         .build()
@@ -856,8 +853,6 @@
                                 .stream()
                                 .filter(instruction -> instruction instanceof ModEtherInstruction)
                                 .findFirst().get()).mac())
-                        .popMpls(IPV4.ethType())
-                        .pushVlan()
                         .setVlanId(((VlanIdCriterion) vlan200Selector.getCriterion(VLAN_VID)).vlanId())
                         .setOutput(d1p11.port())
                         .build()
@@ -1102,12 +1097,12 @@
         assertThat(ruleS1.treatment(), is(
                 DefaultTrafficTreatment
                         .builder()
+                        .setVlanId(((VlanIdCriterion) vlan100Selector.getCriterion(VLAN_VID)).vlanId())
+                        .setOutput(d1p11.port())
                         .popVlan()
                         .pushMpls()
                         .setMpls(((MplsCriterion) mpls100Selector.getCriterion(MPLS_LABEL)).label())
                         .setOutput(d1p10.port())
-                        .setVlanId(((VlanIdCriterion) vlan100Selector.getCriterion(VLAN_VID)).vlanId())
-                        .setOutput(d1p11.port())
                         .build()
         ));
 
@@ -1162,6 +1157,7 @@
                         .pushVlan()
                         .setVlanId(VlanId.vlanId(LABEL))
                         .setOutput(d1p0.port())
+                        .popVlan()
                         .setOutput(d1p11.port())
                         .build()
         ));
@@ -1363,6 +1359,8 @@
                         .pushMpls()
                         .setMpls(MplsLabel.mplsLabel(LABEL))
                         .setOutput(d1p0.port())
+                        .popMpls(IPV4.ethType())
+                        .pushVlan()
                         .setVlanId(((VlanIdCriterion) vlan200Selector.getCriterion(VLAN_VID)).vlanId())
                         .setOutput(d1p11.port())
                         .build()
@@ -1780,8 +1778,6 @@
                                 .stream()
                                 .filter(instruction -> instruction instanceof ModEtherInstruction)
                                 .findFirst().get()).mac())
-                        .popVlan()
-                        .pushMpls()
                         .setMpls(((MplsCriterion) mpls100Selector.getCriterion(MPLS_LABEL)).label())
                         .setOutput(d1p11.port())
                         .build()
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerP2PTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerP2PTest.java
index 7df4af3..44754a6 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerP2PTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerP2PTest.java
@@ -83,7 +83,7 @@
         sut.registrator = registrator;
         sut.resourceService = new MockResourceService();
 
-        LinkCollectionCompiler.optimize = false;
+        LinkCollectionCompiler.optimizeInstructions = false;
         LinkCollectionCompiler.copyTtl = false;
 
         replay(coreService, intentExtensionService);
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 a905eac..f70c69b 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
@@ -104,7 +104,7 @@
         sut.registrator = registrator;
         sut.resourceService = new MockResourceService();
 
-        LinkCollectionCompiler.optimize = false;
+        LinkCollectionCompiler.optimizeInstructions = false;
         LinkCollectionCompiler.copyTtl = false;
 
         replay(coreService, intentExtensionService);
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentObjectiveCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentObjectiveCompilerTest.java
index 22ecf48..613c3cb 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentObjectiveCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentObjectiveCompilerTest.java
@@ -96,7 +96,7 @@
         compiler.registrator = registrator;
         compiler.resourceService = resourceService;
 
-        LinkCollectionCompiler.optimize = false;
+        LinkCollectionCompiler.optimizeInstructions = false;
         LinkCollectionCompiler.copyTtl = false;
 
         replay(coreService, intentExtensionService);
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionOptimizationTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionOptimizationTest.java
index 01b86ba..8038619 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionOptimizationTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionOptimizationTest.java
@@ -83,7 +83,7 @@
         /*
          * We activate the optimizations.
          */
-        LinkCollectionCompiler.optimize = true;
+        LinkCollectionCompiler.optimizeInstructions = true;
         LinkCollectionCompiler.copyTtl = true;
 
         replay(coreService, intentExtensionService);