Fix ONOS-4570

Changes:
- Adds RandomVLAN behavior as described in ONOS-4570;
- Adds a unit test for RandomVLAN;
- Fixes the VLAN rewriting;
- Updates the unit tests relative to VLAN encapsulation;

Change-Id: I52ab2f40a30f3be617606b2b0bb7a89d48414138
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MockResourceService.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MockResourceService.java
index 18ba79e..9da412e 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MockResourceService.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MockResourceService.java
@@ -106,10 +106,25 @@
                 .collect(Collectors.toList());
     }
 
+
+    /**
+     * It adds a number of VLAN ids in order to test the random behavior.
+     *
+     * @param parent the parent resource
+     * @return a set of VLAN ids
+     */
+    private Collection<Resource> addVlanIds(DiscreteResourceId parent) {
+        Collection<Resource> resources = new HashSet<>();
+        for (int i = VlanId.NO_VID + 1; i < VlanId.MAX_VLAN; i++) {
+            resources.add(Resources.discrete(parent).resource().child(VlanId.vlanId((short) i)));
+        }
+        return resources;
+    }
+
     @Override
     public Set<Resource> getAvailableResources(DiscreteResourceId parent) {
         Collection<Resource> resources = new HashSet<>();
-        resources.add(Resources.discrete(parent).resource().child(VlanId.vlanId((short) 10)));
+        resources.addAll(addVlanIds(parent));
         resources.add(Resources.discrete(parent).resource().child(MplsLabel.mplsLabel(10)));
         resources.add(Resources.discrete(parent).resource().child(TributarySlot.of(1)));
         resources.add(Resources.discrete(parent).resource().child(TributarySlot.of(2)));