ONOS-5808: Allocate BW from ConnectivityIntentCompiler and unit tests for partial failure

Change-Id: I2eb3c16efbce619db6d0d2ba415a35752a61ece4
diff --git a/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java b/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java
index 22b0f87..ca61f55 100644
--- a/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java
@@ -120,9 +120,22 @@
         } else {
             String resourceName = resource.simpleTypeName();
             if (resource instanceof ContinuousResource) {
-                print("%s%s: %f", Strings.repeat(" ", level),
-                                  resourceName,
-                                  ((ContinuousResource) resource).value());
+                if (availablesOnly) {
+                    // Get the total resource
+                    double total = ((ContinuousResource) resource).value();
+                    // Get allocated resource
+                    double allocated = resourceService.getResourceAllocations(resource.id()).stream()
+                            .mapToDouble(rA -> ((ContinuousResource) rA.resource()).value())
+                            .sum();
+                    // Difference
+                    double difference = total - allocated;
+                    print("%s%s: %f", Strings.repeat(" ", level),
+                          resourceName, difference);
+                } else {
+                    print("%s%s: %f", Strings.repeat(" ", level),
+                          resourceName,
+                          ((ContinuousResource) resource).value());
+                }
                 // Continuous resource is terminal node, stop here
                 return;
             } else {