Remove dependency on LinkResourceService from Constraint

Change-Id: Ib9c488331b22eef6769a767c6186ef7d2e8b1501
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java
index 6de4cfd..69101a9 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java
@@ -27,8 +27,8 @@
 import org.onosproject.net.intent.IntentCompiler;
 import org.onosproject.net.intent.IntentExtensionService;
 import org.onosproject.net.intent.impl.PathNotFoundException;
+import org.onosproject.net.newresource.ResourceService;
 import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.link.LinkResourceService;
 import org.onosproject.net.topology.LinkWeight;
 import org.onosproject.net.topology.PathService;
 import org.onosproject.net.topology.TopologyEdge;
@@ -55,7 +55,7 @@
     protected PathService pathService;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected LinkResourceService resourceService;
+    protected ResourceService resourceService;
 
     /**
      * Returns an edge-weight capable of evaluating links on the basis of the
@@ -77,7 +77,7 @@
      */
     protected boolean checkPath(Path path, List<Constraint> constraints) {
         for (Constraint constraint : constraints) {
-            if (!constraint.validate(path, resourceService)) {
+            if (!constraint.validate(path, resourceService::isAvailable)) {
                 return false;
             }
         }
@@ -138,9 +138,9 @@
             // the first one with fast fail over the first failure
             Iterator<Constraint> it = constraints.iterator();
 
-            double cost = it.next().cost(edge.link(), resourceService);
+            double cost = it.next().cost(edge.link(), resourceService::isAvailable);
             while (it.hasNext() && cost > 0) {
-                if (it.next().cost(edge.link(), resourceService) < 0) {
+                if (it.next().cost(edge.link(), resourceService::isAvailable) < 0) {
                     return -1;
                 }
             }
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompilerTest.java
index 5588904..4eef4f2 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompilerTest.java
@@ -110,6 +110,7 @@
                 new HostToHostIntentCompiler();
         compiler.pathService = new IntentTestsMocks.MockPathService(hops);
         compiler.hostService = mockHostService;
+        compiler.resourceService = new MockResourceService();
         return compiler;
     }
 
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 c38ea53..f42e179 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
@@ -33,7 +33,7 @@
 import org.onosproject.net.intent.PointToPointIntent;
 import org.onosproject.net.intent.constraint.BandwidthConstraint;
 import org.onosproject.net.intent.impl.PathNotFoundException;
-import org.onosproject.net.resource.link.LinkResourceService;
+import org.onosproject.net.newresource.ResourceService;
 
 import java.util.Collections;
 import java.util.List;
@@ -118,7 +118,7 @@
      * @param resourceService service to use for resource allocation requests
      * @return point to point compiler
      */
-    private PointToPointIntentCompiler makeCompiler(String[] hops, LinkResourceService resourceService) {
+    private PointToPointIntentCompiler makeCompiler(String[] hops, ResourceService resourceService) {
         final PointToPointIntentCompiler compiler = new PointToPointIntentCompiler();
         compiler.resourceService = resourceService;
         compiler.pathService = new IntentTestsMocks.MockPathService(hops);
@@ -223,7 +223,7 @@
     @Test
     public void testBandwidthConstrainedIntentSuccess() {
 
-        final LinkResourceService resourceService =
+        final ResourceService resourceService =
                 IntentTestsMocks.MockResourceService.makeBandwidthResourceService(1000.0);
         final List<Constraint> constraints =
                 Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(100.0)));
@@ -245,7 +245,7 @@
     @Test
     public void testBandwidthConstrainedIntentFailure() {
 
-        final LinkResourceService resourceService =
+        final ResourceService resourceService =
                 IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0);
         final List<Constraint> constraints =
                 Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(100.0)));