Vector cost proposed to TST on 2016-07-13

First part implemented: weight interface introduced and integrated, default weight implementation added.

Change-Id: Ia46f1b44139069aa171a3c13faf168351bd7cc56
diff --git a/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalConnectivityTest.java b/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalConnectivityTest.java
index 1202db3..4f122e1 100644
--- a/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalConnectivityTest.java
+++ b/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalConnectivityTest.java
@@ -20,6 +20,7 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.onlab.graph.Weight;
 import org.onlab.util.Bandwidth;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.DefaultApplicationId;
@@ -287,5 +288,10 @@
         public double cost() {
             return 0;
         }
+
+        @Override
+        public Weight weight() {
+            return null;
+        }
     }
 }
\ No newline at end of file
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
index c49fb27..60a84cc 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
@@ -58,6 +58,7 @@
 import org.onosproject.net.provider.ProviderId;
 import org.onosproject.net.topology.DefaultTopologyEdge;
 import org.onosproject.net.topology.DefaultTopologyVertex;
+import org.onosproject.net.topology.LinkWeigher;
 import org.onosproject.net.topology.LinkWeight;
 import org.onosproject.net.topology.TopologyEdge;
 import org.onosproject.net.topology.TopologyVertex;
@@ -92,6 +93,7 @@
 import static org.onosproject.net.Link.Type.DIRECT;
 import static org.onosproject.net.Link.State.ACTIVE;
 import static org.onosproject.net.DeviceId.deviceId;
+import static org.onosproject.net.topology.AdapterLinkWeigher.adapt;
 import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.COST;
 import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.TE_COST;
 
@@ -184,8 +186,8 @@
      * @param constraints path constraints
      * @return edge-weight function
      */
-    private LinkWeight weight(List<Constraint> constraints) {
-        return new MockTeConstraintBasedLinkWeight(constraints);
+    private LinkWeigher weight(List<Constraint> constraints) {
+        return adapt(new MockTeConstraintBasedLinkWeight(constraints));
     }
 
     private Set<Path> computePath(Link link1, Link link2, Link link3, Link link4, List<Constraint> constraints) {
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
index 54cc1a9..beeabdd 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
@@ -22,6 +22,7 @@
 import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE;
 import static org.onosproject.net.MastershipRole.MASTER;
 import static org.onosproject.net.resource.Resources.continuous;
+import static org.onosproject.net.topology.AdapterLinkWeigher.adapt;
 import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING;
 import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
 import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING;
@@ -119,7 +120,8 @@
 public class PceManagerTest {
 
     private PathComputationTest pathCompTest = new PathComputationTest();
-    private MockPathResourceService resourceService = pathCompTest.new MockPathResourceService();
+    private MockPathResourceService resourceService =
+            pathCompTest.new MockPathResourceService();
     private MockTopologyService topologyService = new MockTopologyService();
     private MockMastershipService mastershipService = new MockMastershipService();
     private MockPathService pathService = new MockPathService();
@@ -128,7 +130,8 @@
     private MockTunnelServiceAdapter tunnelService = new MockTunnelServiceAdapter();
     private TestStorageService storageService = new TestStorageService();
     private MockDeviceService deviceService = new MockDeviceService();
-    private MockNetConfigRegistryAdapter netConfigRegistry = new PathComputationTest.MockNetConfigRegistryAdapter();
+    private MockNetConfigRegistryAdapter netConfigRegistry =
+            new PathComputationTest.MockNetConfigRegistryAdapter();
     private PceStore pceStore = new PceStoreAdapter();
 
     public static ProviderId providerId = new ProviderId("pce", "foo");
@@ -137,12 +140,12 @@
     private static final String PCECC_CAPABILITY = "pceccCapability";
     private static final String SR_CAPABILITY = "srCapability";
     private static final String LABEL_STACK_CAPABILITY = "labelStackCapability";
+    private static final String TUNNEL_NAME = "T123";
 
     private TopologyGraph graph = null;
     private Device deviceD1, deviceD2, deviceD3, deviceD4, deviceD5;
     private Device pcepDeviceD1, pcepDeviceD2, pcepDeviceD3, pcepDeviceD4;
     private Link link1, link2, link3, link4, link5, link6;
-    protected static int flowsDownloaded;
     private TunnelListener tunnelListener;
     private TopologyListener listener;
     private Topology topology;
@@ -177,8 +180,9 @@
         }
     }
 
-    private void build4RouterTopo(boolean setCost, boolean setPceccCap, boolean setSrCap,
-                                 boolean setLabelStackCap, int bandwidth) {
+    private void build4RouterTopo(boolean setCost, boolean setPceccCap,
+                                  boolean setSrCap, boolean setLabelStackCap,
+                                  int bandwidth) {
         link1 = PathComputationTest.addLink(DEVICE1, 10, DEVICE2, 20, setCost, 50);
         link2 = PathComputationTest.addLink(DEVICE2, 30, DEVICE4, 40, setCost, 20);
         link3 = PathComputationTest.addLink(DEVICE1, 80, DEVICE3, 70, setCost, 100);
@@ -252,65 +256,63 @@
         deviceService.addDevice(deviceD4);
         deviceService.addDevice(deviceD5);
 
-        DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class);
-        device1Cap.setLabelStackCap(setLabelStackCap)
-        .setLocalLabelCap(setPceccCap)
-        .setSrCap(setSrCap)
-        .apply();
-
-        DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class);
-        device2Cap.setLabelStackCap(setLabelStackCap)
-        .setLocalLabelCap(setPceccCap)
-        .setSrCap(setSrCap)
-        .apply();
-
-        DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class);
-        device3Cap.setLabelStackCap(setLabelStackCap)
-        .setLocalLabelCap(setPceccCap)
-        .setSrCap(setSrCap)
-        .apply();
-
-        DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class);
-        device4Cap.setLabelStackCap(setLabelStackCap)
-        .setLocalLabelCap(setPceccCap)
-        .setSrCap(setSrCap)
-        .apply();
-
-        DeviceCapability device5Cap = netConfigRegistry.addConfig(DeviceId.deviceId("5.5.5.5"), DeviceCapability.class);
-        device4Cap.setLabelStackCap(setLabelStackCap)
-                .setLocalLabelCap(setPceccCap)
-                .setSrCap(setSrCap)
-                .apply();
+        mkDevCap("1.1.1.1", setLabelStackCap, setPceccCap, setSrCap);
+        mkDevCap("2.2.2.2", setLabelStackCap, setPceccCap, setSrCap);
+        mkDevCap("3.3.3.3", setLabelStackCap, setPceccCap, setSrCap);
+        mkDevCap("4.4.4.4", setLabelStackCap, setPceccCap, setSrCap);
+        mkDevCap("5.5.5.5", setLabelStackCap, setPceccCap, setSrCap);
 
         if (bandwidth != 0) {
             List<Resource> resources = new LinkedList<>();
-            resources.add(continuous(link1.src().deviceId(), link1.src().port(), Bandwidth.class).resource(bandwidth));
-            resources.add(continuous(link2.src().deviceId(), link2.src().port(), Bandwidth.class).resource(bandwidth));
-            resources.add(continuous(link3.src().deviceId(), link3.src().port(), Bandwidth.class).resource(bandwidth));
-            resources.add(continuous(link4.src().deviceId(), link4.src().port(), Bandwidth.class).resource(bandwidth));
-            resources.add(continuous(link5.src().deviceId(), link5.src().port(), Bandwidth.class).resource(bandwidth));
 
-            resources.add(continuous(link1.dst().deviceId(), link1.dst().port(), Bandwidth.class).resource(bandwidth));
-            resources.add(continuous(link2.dst().deviceId(), link2.dst().port(), Bandwidth.class).resource(bandwidth));
-            resources.add(continuous(link3.dst().deviceId(), link3.dst().port(), Bandwidth.class).resource(bandwidth));
-            resources.add(continuous(link4.dst().deviceId(), link4.dst().port(), Bandwidth.class).resource(bandwidth));
-            resources.add(continuous(link5.dst().deviceId(), link5.dst().port(), Bandwidth.class).resource(bandwidth));
+            resources.add(continuous(link1.src().deviceId(), link1.src().port(),
+                    Bandwidth.class).resource(bandwidth));
+            resources.add(continuous(link2.src().deviceId(), link2.src().port(),
+                    Bandwidth.class).resource(bandwidth));
+            resources.add(continuous(link3.src().deviceId(), link3.src().port(),
+                    Bandwidth.class).resource(bandwidth));
+            resources.add(continuous(link4.src().deviceId(), link4.src().port(),
+                    Bandwidth.class).resource(bandwidth));
+            resources.add(continuous(link5.src().deviceId(), link5.src().port(),
+                    Bandwidth.class).resource(bandwidth));
+
+            resources.add(continuous(link1.dst().deviceId(), link1.dst().port(),
+                    Bandwidth.class).resource(bandwidth));
+            resources.add(continuous(link2.dst().deviceId(), link2.dst().port(),
+                    Bandwidth.class).resource(bandwidth));
+            resources.add(continuous(link3.dst().deviceId(), link3.dst().port(),
+                    Bandwidth.class).resource(bandwidth));
+            resources.add(continuous(link4.dst().deviceId(), link4.dst().port(),
+                    Bandwidth.class).resource(bandwidth));
+            resources.add(continuous(link5.dst().deviceId(), link5.dst().port(),
+                    Bandwidth.class).resource(bandwidth));
 
             resourceService.allocate(IntentId.valueOf(bandwidth), resources);
         }
     }
 
+    private void mkDevCap(String strDeviceId, boolean setLabelStackCap,
+                          boolean setPceccCap, boolean setSrCap) {
+        DeviceCapability deviceCap = netConfigRegistry.addConfig(
+                DeviceId.deviceId(strDeviceId), DeviceCapability.class);
+        deviceCap.setLabelStackCap(setLabelStackCap)
+                .setLocalLabelCap(setPceccCap)
+                .setSrCap(setSrCap)
+                .apply();
+    }
+
     /**
      * Tests path success with (IGP) cost constraint for signalled LSP.
      */
     @Test
-    public void setupPathTest1() {
+    public void setupPathSuccessIgpCostSignalledLsp() {
         build4RouterTopo(true, false, false, false, 0); // IGP cost is set here.
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(COST);
         constraints.add(costConstraint);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(true));
     }
 
@@ -318,13 +320,15 @@
      * Tests path failure with (IGP) cost constraint for signalled LSP.
      */
     @Test
-    public void setupPathTest2() {
-        build4RouterTopo(false, false, false, false, 0); // TE cost is set here, not IGP.
-        List<Constraint> constraints = new LinkedList<Constraint>();
+    public void setupPathFailureIgpCostSignalledLsp() {
+        // TE cost is set here, not IGP.
+        build4RouterTopo(false, false, false, false, 0);
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(COST);
         constraints.add(costConstraint);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(false));
     }
 
@@ -332,14 +336,16 @@
      * Tests path success with TE-cost constraint for signalled LSP.
      */
     @Test
-    public void setupPathTest3() {
-        build4RouterTopo(false, false, false, false, 0); // TE cost is set here.
+    public void setupPathSuccessTeCostSignalledLsp() {
+        // TE cost is set here.
+        build4RouterTopo(false, false, false, false, 0);
 
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(TE_COST);
         constraints.add(costConstraint);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(true));
     }
 
@@ -347,14 +353,16 @@
      * Tests path failure with TE-cost constraint for signalled LSP.
      */
     @Test
-    public void setupPathTest4() {
-        build4RouterTopo(true, false, false, false, 0); // IGP cost is set here, not TE.
+    public void setupPathFailureTeCostSignalledLsp() {
+        // IGP cost is set here, not TE.
+        build4RouterTopo(true, false, false, false, 0);
 
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(TE_COST);
         constraints.add(costConstraint);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(false));
     }
 
@@ -362,15 +370,16 @@
      * Tests path success with (IGP) cost constraint for non-SR non-signalled LSP.
      */
     @Test
-    public void setupPathTest5() {
+    public void setupPathSuccessIgpCostNonSignalledLsp() {
         build4RouterTopo(true, true, false, false, 0);
 
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(COST);
         constraints.add(costConstraint);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints,
-                                              WITHOUT_SIGNALLING_AND_WITHOUT_SR, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, constraints, WITHOUT_SIGNALLING_AND_WITHOUT_SR,
+                null);
         assertThat(result, is(true));
     }
 
@@ -378,31 +387,34 @@
      * Tests path success with TE-cost constraint for non-SR non-sgnalled LSP.
      */
     @Test
-    public void setupPathTest6() {
+    public void setupPathSuccessTeCostNonSignalledLsp() {
         build4RouterTopo(false, true, false, false, 0);
 
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(TE_COST);
         constraints.add(costConstraint);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints,
-                                              WITHOUT_SIGNALLING_AND_WITHOUT_SR, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, constraints, WITHOUT_SIGNALLING_AND_WITHOUT_SR,
+                null);
         assertThat(result, is(true));
     }
 
     /**
-     * Tests path failure with TE-cost constraint for non-SR non-signalled LSP(CR). Label capability not registered.
+     * Tests path failure with TE-cost constraint for non-SR
+     * non-signalled LSP(CR). Label capability not registered.
      */
     @Test
-    public void setupPathTest7() {
+    public void setupPathFailureTeCostNonSignalledLsp() {
         build4RouterTopo(true, false, false, false, 0);
 
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(TE_COST);
         constraints.add(costConstraint);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints,
-                                              WITHOUT_SIGNALLING_AND_WITHOUT_SR, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, constraints, WITHOUT_SIGNALLING_AND_WITHOUT_SR,
+                null);
         assertThat(result, is(false));
     }
 
@@ -410,17 +422,18 @@
      * Tests path failure as bandwidth is requested but is not registered.
      */
     @Test
-    public void setupPathTest8() {
+    public void setupPathFailureBandwidthNotRegistered() {
         build4RouterTopo(true, false, false, false, 0);
-        List<Constraint> constraints = new LinkedList<Constraint>();
-        BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(10.0));
+        List<Constraint> constraints = new LinkedList<>();
+        BandwidthConstraint bwConstraint = new BandwidthConstraint(
+                Bandwidth.bps(10.0));
         CostConstraint costConstraint = new CostConstraint(TE_COST);
 
         constraints.add(costConstraint);
         constraints.add(bwConstraint);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints,
-                WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(false));
     }
 
@@ -428,32 +441,34 @@
      * Tests path failure as bandwidth requested is more than registered.
      */
     @Test
-    public void setupPathTest9() {
+    public void setupPathFailureNotEnoughBandwidthRegistered() {
         build4RouterTopo(false, false, false, false, 5);
-        List<Constraint> constraints = new LinkedList<Constraint>();
-        BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(10.0));
+        List<Constraint> constraints = new LinkedList<>();
+        BandwidthConstraint bwConstraint = new BandwidthConstraint(
+                Bandwidth.bps(10.0));
         CostConstraint costConstraint = new CostConstraint(TE_COST);
 
         constraints.add(costConstraint);
         constraints.add(bwConstraint);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(false));
     }
 
     /**
-     * Tests path setup failure(without signalling). Label capability is not present.
+     * Tests path setup failure(without signalling). Label capability is not
+     * present.
      */
     @Test
-    public void setupPathTest10() {
+    public void setupPathFailureNoLabelCapability() {
         build4RouterTopo(false, false, false, false, 0);
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(TE_COST);
         constraints.add(costConstraint);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints,
-             SR_WITHOUT_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, constraints, SR_WITHOUT_SIGNALLING, null);
         assertThat(result, is(false));
     }
 
@@ -461,17 +476,18 @@
      * Tests path setup without signalling and with bandwidth reservation.
      */
     @Test
-    public void setupPathTest12() {
+    public void setupPathSuccessWithoutSignalling() {
         build4RouterTopo(false, true, true, true, 15);
-        List<Constraint> constraints = new LinkedList<Constraint>();
-        BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(10.0));
+        List<Constraint> constraints = new LinkedList<>();
+        BandwidthConstraint bwConstraint = new BandwidthConstraint(
+                Bandwidth.bps(10.0));
         CostConstraint costConstraint = new CostConstraint(TE_COST);
 
         constraints.add(costConstraint);
         constraints.add(bwConstraint);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123",
-                constraints, SR_WITHOUT_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, constraints, SR_WITHOUT_SIGNALLING, null);
         assertThat(result, is(true));
     }
 
@@ -479,26 +495,28 @@
      * Tests path setup without cost/bandwidth constraints.
      */
     @Test
-    public void setupPathTest13() {
+    public void setupPathSuccessWithoutConstraints() {
         build4RouterTopo(false, false, false, false, 0);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", null, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, null, WITH_SIGNALLING, null);
         assertThat(result, is(true));
     }
 
     /**
      * Tests path setup with explicit path with loose node D2.
      */
-   @Test
-    public void setupPathTest14() {
+    @Test
+    public void setupPathExplicitPathInfoLooseD2() {
         build4RouterTopo(false, false, false, false, 0);
 
         List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
-        ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D2.deviceId());
+        ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE,
+                D2.deviceId());
         explicitPathInfoList.add(obj);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123", null, WITH_SIGNALLING,
-                explicitPathInfoList);
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(),
+                TUNNEL_NAME, null, WITH_SIGNALLING, explicitPathInfoList);
 
         Tunnel tunnel = pceManager.queryAllPath().iterator().next();
         List<Link> links = new LinkedList<>();
@@ -512,129 +530,136 @@
     /**
      * Tests path setup with explicit path with loose node D3.
      */
-   @Test
-   public void setupPathTest15() {
-       build4RouterTopo(false, false, false, false, 0);
+    @Test
+    public void setupPathExplicitPathInfoLooseD3() {
+        build4RouterTopo(false, false, false, false, 0);
 
-       List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
-       ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D3.deviceId());
-       explicitPathInfoList.add(obj);
+        List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
+        ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE,
+                D3.deviceId());
+        explicitPathInfoList.add(obj);
 
-       boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(), "T123", null, WITH_SIGNALLING,
-               explicitPathInfoList);
+        boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(),
+                TUNNEL_NAME, null, WITH_SIGNALLING, explicitPathInfoList);
 
-       Tunnel tunnel = pceManager.queryAllPath().iterator().next();
-       List<Link> links = new LinkedList<>();
-       links.add(link3);
-       links.add(link4);
-       links.add(link6);
+        Tunnel tunnel = pceManager.queryAllPath().iterator().next();
+        List<Link> links = new LinkedList<>();
+        links.add(link3);
+        links.add(link4);
+        links.add(link6);
 
-       assertThat(result, is(true));
-       assertThat(tunnel.path().links().equals(links), is(true));
-   }
+        assertThat(result, is(true));
+        assertThat(tunnel.path().links().equals(links), is(true));
+    }
 
     /**
      * Tests path setup with explicit path with loose node D4 , D3 - path fails.
      */
-   @Test
-   public void setupPathTest16() {
-       build4RouterTopo(false, false, false, false, 0);
+    @Test
+    public void setupPathExplicitPathInfoFail() {
+        build4RouterTopo(false, false, false, false, 0);
 
-       List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
-       ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D4.deviceId());
-       explicitPathInfoList.add(obj);
-       obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D3.deviceId());
-       explicitPathInfoList.add(obj);
+        List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
+        ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE,
+                D4.deviceId());
+        explicitPathInfoList.add(obj);
+        obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D3.deviceId());
+        explicitPathInfoList.add(obj);
 
-       boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(), "T123", null, WITH_SIGNALLING,
-               explicitPathInfoList);
+        boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(),
+                TUNNEL_NAME, null, WITH_SIGNALLING, explicitPathInfoList);
 
-       assertThat(result, is(false));
-   }
+        assertThat(result, is(false));
+    }
 
     /**
-     * Tests path setup with explicit path with strict node D2 - without reacble to src - path fails.
+     * Tests path setup with explicit path with strict node D2 - without reacble
+     * to src - path fails.
      */
-   @Test
-   public void setupPathTest17() {
-       build4RouterTopo(false, false, false, false, 0);
+    @Test
+    public void setupPathExplicitPathInfoStrictD2Fail() {
+        build4RouterTopo(false, false, false, false, 0);
 
-       List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
-       ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
-       explicitPathInfoList.add(obj);
+        List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
+        ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT,
+                D2.deviceId());
+        explicitPathInfoList.add(obj);
 
-       boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(), "T123", null, WITH_SIGNALLING,
-               explicitPathInfoList);
+        boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(),
+                TUNNEL_NAME, null, WITH_SIGNALLING, explicitPathInfoList);
 
-       assertThat(result, is(false));
-   }
+        assertThat(result, is(false));
+    }
 
     /**
      * Tests path setup with explicit path with loose node D2, strict D2.
      */
-   @Test
-   public void setupPathTest18() {
-       build4RouterTopo(false, false, false, false, 0);
+    @Test
+    public void setupPathExplicitPathInfoLooseAndStrictD2() {
+        build4RouterTopo(false, false, false, false, 0);
 
-       List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
-       ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D2.deviceId());
-       explicitPathInfoList.add(obj);
-       obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
-       explicitPathInfoList.add(obj);
+        List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
+        ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE,
+                D2.deviceId());
+        explicitPathInfoList.add(obj);
+        obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
+        explicitPathInfoList.add(obj);
 
-       boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(), "T123", null, WITH_SIGNALLING,
-               explicitPathInfoList);
+        boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(),
+                TUNNEL_NAME, null, WITH_SIGNALLING, explicitPathInfoList);
 
-       Tunnel tunnel = pceManager.queryAllPath().iterator().next();
-       List<Link> links = new LinkedList<>();
-       links.add(link1);
-       links.add(link5);
+        Tunnel tunnel = pceManager.queryAllPath().iterator().next();
+        List<Link> links = new LinkedList<>();
+        links.add(link1);
+        links.add(link5);
 
-       assertThat(result, is(true));
-       assertThat(tunnel.path().links().equals(links), is(true));
-   }
+        assertThat(result, is(true));
+        assertThat(tunnel.path().links().equals(links), is(true));
+    }
 
     /**
      * Tests path setup with explicit path with loose D1-D2, strict D2.
      */
-   @Test
-   public void setupPathTest19() {
-       build4RouterTopo(false, false, false, false, 0);
+    @Test
+    public void setupPathExplicitPathInfoLooseLink1StrictD2() {
+        build4RouterTopo(false, false, false, false, 0);
 
-       List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
-       ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, link1);
-       explicitPathInfoList.add(obj);
-       obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
-       explicitPathInfoList.add(obj);
+        List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
+        ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE,
+                link1);
+        explicitPathInfoList.add(obj);
+        obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
+        explicitPathInfoList.add(obj);
 
-       boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(), "T123", null, WITH_SIGNALLING,
-               explicitPathInfoList);
+        boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(),
+                TUNNEL_NAME, null, WITH_SIGNALLING, explicitPathInfoList);
 
-       Tunnel tunnel = pceManager.queryAllPath().iterator().next();
-       List<Link> links = new LinkedList<>();
-       links.add(link1);
-       links.add(link5);
+        Tunnel tunnel = pceManager.queryAllPath().iterator().next();
+        List<Link> links = new LinkedList<>();
+        links.add(link1);
+        links.add(link5);
 
-       assertThat(result, is(true));
-       assertThat(tunnel.path().links().equals(links), is(true));
-   }
+        assertThat(result, is(true));
+        assertThat(tunnel.path().links().equals(links), is(true));
+    }
 
     /**
      * Tests path update with increase in bandwidth.
      */
     @Test
-    public void updatePathTest1() {
+    public void updatePathIncreaseBandwidth() {
         build4RouterTopo(false, true, true, true, 100);
 
         // Setup tunnel.
         List<Constraint> constraints = new LinkedList<>();
-        BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(60.0));
+        BandwidthConstraint bwConstraint = new BandwidthConstraint(
+                Bandwidth.bps(60.0));
         constraints.add(bwConstraint);
         CostConstraint costConstraint = new CostConstraint(TE_COST);
         constraints.add(costConstraint);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(true));
 
         // Change constraint and update it.
@@ -662,18 +687,19 @@
      * Tests path update with decrease in bandwidth.
      */
     @Test
-    public void updatePathTest2() {
+    public void updatePathDecreaseBandwidth() {
         build4RouterTopo(false, true, true, true, 100);
 
         // Setup tunnel.
-        List<Constraint> constraints = new LinkedList<Constraint>();
-        BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(60.0));
+        List<Constraint> constraints = new LinkedList<>();
+        BandwidthConstraint bwConstraint = new BandwidthConstraint(
+                Bandwidth.bps(60.0));
         constraints.add(bwConstraint);
         CostConstraint costConstraint = new CostConstraint(TE_COST);
         constraints.add(costConstraint);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123",
-                constraints, SR_WITHOUT_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, constraints, SR_WITHOUT_SIGNALLING, null);
         assertThat(result, is(true));
 
         // Change constraint and update it.
@@ -697,15 +723,15 @@
      * Tests path update without cost/bandwidth constraints.
      */
     @Test
-    public void updatePathTest3() {
+    public void updatePathWithoutConstraints() {
         build4RouterTopo(false, true, true, true, 100);
 
         // Setup tunnel.
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(TE_COST);
         constraints.add(costConstraint);
-        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(true));
 
         Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
@@ -717,31 +743,35 @@
         }
 
         Iterable<Tunnel> queryTunnelResult = pceManager.queryAllPath();
-        assertThat((int) queryTunnelResult.spliterator().getExactSizeIfKnown(), is(2));
+        assertThat((int) queryTunnelResult.spliterator().getExactSizeIfKnown(),
+                is(2));
     }
 
     /**
-     * Tests path update without cost/bandwidth constraints and with explicit path object.
+     * Tests path update without cost/bandwidth constraints and with explicit
+     * path object.
      */
     @Test
-    public void updatePathTest4() {
+    public void updatePathExplicitPathInfo() {
         build4RouterTopo(false, true, true, true, 100);
 
         // Setup tunnel.
         List<Constraint> constraints = new LinkedList<>();
-        BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(60.0));
+        BandwidthConstraint bwConstraint = new BandwidthConstraint(
+                Bandwidth.bps(60.0));
         constraints.add(bwConstraint);
         CostConstraint costConstraint = new CostConstraint(TE_COST);
         constraints.add(costConstraint);
 
         List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
-        ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, link1);
+        ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE,
+                link1);
         explicitPathInfoList.add(obj);
         obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
         explicitPathInfoList.add(obj);
 
-        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, explicitPathInfoList);
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, explicitPathInfoList);
         assertThat(result, is(true));
 
         // Change constraint and update it.
@@ -766,12 +796,12 @@
     }
 
     /**
-     * Tests path release.
+     * Tests path release with explicit info.
      */
     @Test
-    public void releasePathTest1() {
+    public void releasePathExplicitPathInfo() {
         build4RouterTopo(false, false, false, false, 5);
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(TE_COST);
         BandwidthConstraint bwConst = new BandwidthConstraint(Bandwidth.bps(3));
         constraints.add(bwConst);
@@ -783,7 +813,8 @@
         obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
         explicitPathInfoList.add(obj);
 
-        pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, explicitPathInfoList);
+        pceManager.setupPath(D1.deviceId(), D2.deviceId(), TUNNEL_NAME,
+                constraints, WITH_SIGNALLING, explicitPathInfoList);
 
         Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
         assertThat(tunnels.size(), is(1));
@@ -800,13 +831,14 @@
      * Tests path release failure.
      */
     @Test
-    public void releasePathTest2() {
+    public void releasePathFailure() {
         build4RouterTopo(false, false, false, false, 5);
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(TE_COST);
         constraints.add(costConstraint);
 
-        pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, null);
+        pceManager.setupPath(D1.deviceId(), D2.deviceId(), TUNNEL_NAME,
+                constraints, WITH_SIGNALLING, null);
 
         Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
         assertThat(tunnels.size(), is(1));
@@ -820,10 +852,10 @@
     }
 
     /**
-     * Tests path release failure.
+     * Tests path release.
      */
     @Test
-    public void releasePathTest3() {
+    public void releasePath() {
         build4RouterTopo(false, false, false, false, 5);
         List<Constraint> constraints = new LinkedList<Constraint>();
         CostConstraint costConstraint = new CostConstraint(TE_COST);
@@ -831,7 +863,8 @@
         constraints.add(bwConst);
         constraints.add(costConstraint);
 
-        pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, null);
+        pceManager.setupPath(D1.deviceId(), D2.deviceId(), TUNNEL_NAME,
+                constraints, WITH_SIGNALLING, null);
 
         Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
         assertThat(tunnels.size(), is(1));
@@ -848,22 +881,25 @@
      * Tests tunnel events added and removed.
      */
     @Test
-    public void tunnelEventTest1() {
+    public void tunnelEventAddedRemoved() {
         build4RouterTopo(false, true, true, true, 15);
-        List<Constraint> constraints = new LinkedList<Constraint>();
-        BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(10.0));
+        List<Constraint> constraints = new LinkedList<>();
+        BandwidthConstraint bwConstraint = new BandwidthConstraint(
+                Bandwidth.bps(10.0));
         CostConstraint costConstraint = new CostConstraint(TE_COST);
 
         constraints.add(costConstraint);
         constraints.add(bwConstraint);
 
-        pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T1", constraints, SR_WITHOUT_SIGNALLING, null);
+        pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T1", constraints,
+                SR_WITHOUT_SIGNALLING, null);
         assertThat(pceStore.getTunnelInfoCount(), is(1));
 
         Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
 
         for (Tunnel tunnel : tunnels) {
-            TunnelEvent event = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, tunnel);
+            TunnelEvent event = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED,
+                    tunnel);
             tunnelListener.event(event);
 
             pceManager.releasePath(tunnel.tunnelId());
@@ -879,10 +915,11 @@
      * Tests label allocation/removal in CR case based on tunnel event.
      */
     @Test
-    public void tunnelEventTest2() {
+    public void labelAllocationRemoval() {
         build4RouterTopo(false, true, true, true, 15);
-        List<Constraint> constraints = new LinkedList<Constraint>();
-        BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(10.0));
+        List<Constraint> constraints = new LinkedList<>();
+        BandwidthConstraint bwConstraint = new BandwidthConstraint(
+                Bandwidth.bps(10.0));
         CostConstraint costConstraint = new CostConstraint(TE_COST);
 
         constraints.add(costConstraint);
@@ -920,10 +957,11 @@
      * Tests handling UNSTABLE state based on tunnel event.
      */
     @Test
-    public void tunnelEventTest3() {
+    public void tunnelEventUnstable() {
         build4RouterTopo(false, true, true, true, 15);
-        List<Constraint> constraints = new LinkedList<Constraint>();
-        BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(10.0));
+        List<Constraint> constraints = new LinkedList<>();
+        BandwidthConstraint bwConstraint = new BandwidthConstraint(
+                Bandwidth.bps(10.0));
         CostConstraint costConstraint = new CostConstraint(TE_COST);
 
         constraints.add(costConstraint);
@@ -954,28 +992,30 @@
     }
 
     /**
-     * Tests resilency when L2 link is down.
+     * Tests resiliency when L2 link is down.
      */
     @Test
-    public void resilencyTest1() {
+    public void resiliencyLinkFail() {
         build4RouterTopo(true, false, false, false, 10);
 
 
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(COST);
         constraints.add(costConstraint);
-        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        BandwidthConstraint localBwConst = new BandwidthConstraint(
+                Bandwidth.bps(10));
         constraints.add(localBwConst);
 
         //Setup the path , tunnel created
-        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(true));
         assertThat(pceStore.getTunnelInfoCount(), is(1));
         assertThat(pceStore.getFailedPathInfoCount(), is(0));
 
         List<Event> reasons = new LinkedList<>();
-        final LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
+        final LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED,
+                link2);
         reasons.add(linkEvent);
         final TopologyEvent event = new TopologyEvent(
                 TopologyEvent.Type.TOPOLOGY_CHANGED,
@@ -985,7 +1025,7 @@
         //Change Topology : remove link2
         Set<TopologyEdge> tempEdges = new HashSet<>();
         tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
-        topologyService.changeInTopology(getGraph(null,  tempEdges));
+        topologyService.changeInTopology(getGraph(null, tempEdges));
         listener.event(event);
 
         List<Link> links = new LinkedList<>();
@@ -998,21 +1038,22 @@
     }
 
     /**
-     * Tests resilency when L2 and L4 link is down.
+     * Tests resiliency when L2 and L4 link is down.
      */
     @Test
-    public void resilencyTest2() {
+    public void resiliencyMultipleLinkFailsNoAlternativePath() {
         build4RouterTopo(true, false, false, false, 10);
 
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(COST);
         constraints.add(costConstraint);
-        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        BandwidthConstraint localBwConst = new BandwidthConstraint(
+                Bandwidth.bps(10));
         constraints.add(localBwConst);
 
         //Setup the path , tunnel created
-        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(true));
 
         List<Event> reasons = new LinkedList<>();
@@ -1029,7 +1070,7 @@
         Set<TopologyEdge> tempEdges = new HashSet<>();
         tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
         tempEdges.add(new DefaultTopologyEdge(D3, D4, link4));
-        topologyService.changeInTopology(getGraph(null,  tempEdges));
+        topologyService.changeInTopology(getGraph(null, tempEdges));
         listener.event(event);
 
         //No Path
@@ -1037,21 +1078,22 @@
     }
 
     /**
-     * Tests resilency when D2 device is down.
+     * Tests resiliency when D2 device is down.
      */
     @Test
-    public void resilencyTest3() {
+    public void resiliencyDeviceFail() {
         build4RouterTopo(true, false, false, false, 10);
 
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(COST);
         constraints.add(costConstraint);
-        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        BandwidthConstraint localBwConst = new BandwidthConstraint(
+                Bandwidth.bps(10));
         constraints.add(localBwConst);
 
         //Setup the path , tunnel created
-        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(true));
 
         List<Event> reasons = new LinkedList<>();
@@ -1068,7 +1110,7 @@
         Set<TopologyEdge> tempEdges = new HashSet<>();
         tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
         tempEdges.add(new DefaultTopologyEdge(D1, D2, link1));
-        topologyService.changeInTopology(getGraph(null,  tempEdges));
+        topologyService.changeInTopology(getGraph(null, tempEdges));
         listener.event(event);
 
         List<Link> links = new LinkedList<>();
@@ -1081,21 +1123,22 @@
     }
 
     /**
-     * Tests resilency when ingress device is down.
+     * Tests resiliency when ingress device is down.
      */
     @Test
-    public void resilencyTest4() {
+    public void resiliencyIngressDeviceFail() {
         build4RouterTopo(true, false, false, false, 10);
 
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(COST);
         constraints.add(costConstraint);
-        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        BandwidthConstraint localBwConst = new BandwidthConstraint(
+                Bandwidth.bps(10));
         constraints.add(localBwConst);
 
         //Setup the path , tunnel created
-        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(true));
 
         List<Event> reasons = new LinkedList<>();
@@ -1120,21 +1163,22 @@
     }
 
     /**
-     * Tests resilency when D2 and D3 devices are down.
+     * Tests resiliency when D2 and D3 devices are down.
      */
     @Test
-    public void resilencyTest5() {
+    public void resiliencyMultipleDevicesFailNoAlternativePath() {
         build4RouterTopo(true, false, false, false, 10);
 
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(COST);
         constraints.add(costConstraint);
-        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        BandwidthConstraint localBwConst = new BandwidthConstraint(
+                Bandwidth.bps(10));
         constraints.add(localBwConst);
 
         //Setup the path , tunnel created
-        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(true));
 
         List<Event> reasons = new LinkedList<>();
@@ -1169,21 +1213,22 @@
     }
 
     /**
-     * Tests resilency when egress device is down.
+     * Tests resiliency when egress device is down.
      */
     @Test
-    public void resilencyTest6() {
+    public void resiliencyEgressDeviceFail() {
         build4RouterTopo(true, false, false, false, 10);
 
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(COST);
         constraints.add(costConstraint);
-        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        BandwidthConstraint localBwConst = new BandwidthConstraint(
+                Bandwidth.bps(10));
         constraints.add(localBwConst);
 
         //Setup the path , tunnel created
-        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(true));
 
         List<Event> reasons = new LinkedList<>();
@@ -1211,110 +1256,22 @@
     }
 
     /**
-     * Tests resilency when egress device is down.
+     * Tests resiliency when D2 device is suspended.
      */
     @Test
-    public void resilencyTest7() {
+    public void resiliencyDeviceSuspended() {
         build4RouterTopo(true, false, false, false, 10);
 
-        List<Constraint> constraints = new LinkedList<Constraint>();
+        List<Constraint> constraints = new LinkedList<>();
         CostConstraint costConstraint = new CostConstraint(COST);
         constraints.add(costConstraint);
-        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        BandwidthConstraint localBwConst = new BandwidthConstraint(
+                Bandwidth.bps(10));
         constraints.add(localBwConst);
 
         //Setup the path , tunnel created
-        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, null);
-        assertThat(result, is(true));
-
-        List<Event> reasons = new LinkedList<>();
-        LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
-        reasons.add(linkEvent);
-        linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link4);
-        reasons.add(linkEvent);
-
-        final TopologyEvent event = new TopologyEvent(
-                TopologyEvent.Type.TOPOLOGY_CHANGED,
-                topology,
-                reasons);
-
-        //Change Topology : remove device4 , link2 and link4
-        Set<TopologyEdge> tempEdges = new HashSet<>();
-        tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
-        tempEdges.add(new DefaultTopologyEdge(D3, D4, link4));
-        Set<TopologyVertex> tempVertexes = new HashSet<>();
-        tempVertexes.add(D4);
-        topologyService.changeInTopology(getGraph(tempVertexes, tempEdges));
-        listener.event(event);
-
-        //No path
-        assertThat(pathService.paths().size(), is(0));
-    }
-
-    /**
-     * Tests resilency when D2 device is suspended.
-     */
-    @Test
-    public void resilencyTest8() {
-        build4RouterTopo(true, false, false, false, 10);
-
-        List<Constraint> constraints = new LinkedList<Constraint>();
-        CostConstraint costConstraint = new CostConstraint(COST);
-        constraints.add(costConstraint);
-        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
-        constraints.add(localBwConst);
-
-        //Setup the path , tunnel created
-        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, null);
-        assertThat(result, is(true));
-
-        List<Event> reasons = new LinkedList<>();
-        LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link1);
-        reasons.add(linkEvent);
-        linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
-        reasons.add(linkEvent);
-
-        final TopologyEvent event = new TopologyEvent(
-                TopologyEvent.Type.TOPOLOGY_CHANGED,
-                topology,
-                reasons);
-
-        //Change Topology : remove device2 , link1 and link2
-        Set<TopologyEdge> tempEdges = new HashSet<>();
-        tempEdges.add(new DefaultTopologyEdge(D1, D2, link1));
-        tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
-        Set<TopologyVertex> tempVertexes = new HashSet<>();
-        tempVertexes.add(D2);
-        topologyService.changeInTopology(getGraph(tempVertexes, tempEdges));
-        listener.event(event);
-
-        List<Link> links = new LinkedList<>();
-        links.add(link3);
-        links.add(link4);
-
-        //Path is D1-D3-D4
-        assertThat(pathService.paths().iterator().next().links(), is(links));
-        assertThat(pathService.paths().iterator().next().cost(), is((double) 180));
-    }
-
-    /**
-     * Tests resilency when D2 device availability is changed.
-     */
-    @Test
-    public void resilencyTest11() {
-        build4RouterTopo(true, false, false, false, 10);
-
-        List<Constraint> constraints = new LinkedList<Constraint>();
-        CostConstraint costConstraint = new CostConstraint(COST);
-        constraints.add(costConstraint);
-        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
-        constraints.add(localBwConst);
-
-        //Setup the path , tunnel created
-        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, null);
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, null);
         assertThat(result, is(true));
 
         List<Event> reasons = new LinkedList<>();
@@ -1350,30 +1307,33 @@
      * Tests resilency when link2 availability is changed.
      */
     @Test
-    public void resilencyTest12() {
+    public void resilencyExplicitPathInfoSpecified() {
         build4RouterTopo(true, false, false, false, 10);
 
         List<Constraint> constraints = new LinkedList<Constraint>();
         CostConstraint costConstraint = new CostConstraint(COST);
         constraints.add(costConstraint);
-        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        BandwidthConstraint localBwConst = new BandwidthConstraint(
+                Bandwidth.bps(10));
         constraints.add(localBwConst);
 
         List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
-        ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, link1);
+        ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE,
+                link1);
         explicitPathInfoList.add(obj);
         obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
         explicitPathInfoList.add(obj);
 
         //Setup the path , tunnel created
-        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
-                constraints, WITH_SIGNALLING, explicitPathInfoList);
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(),
+                TUNNEL_NAME, constraints, WITH_SIGNALLING, explicitPathInfoList);
         assertThat(result, is(true));
         assertThat(pceStore.getTunnelInfoCount(), is(1));
         assertThat(pceStore.getFailedPathInfoCount(), is(0));
 
         List<Event> reasons = new LinkedList<>();
-        final LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
+        final LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED,
+                link2);
         reasons.add(linkEvent);
         final TopologyEvent event = new TopologyEvent(
                 TopologyEvent.Type.TOPOLOGY_CHANGED,
@@ -1407,7 +1367,6 @@
         pceManager.pceStore = null;
         pceManager.topologyService = null;
         pceManager.mastershipService = null;
-        flowsDownloaded = 0;
     }
 
     private class MockTopologyService extends TopologyServiceAdapter {
@@ -1416,7 +1375,8 @@
         }
 
         @Override
-        public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
+        public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
+                                  LinkWeight weight) {
             DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
             DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
             Set<TopologyVertex> vertices = graph.getVertexes();
@@ -1425,8 +1385,9 @@
                 return ImmutableSet.of();
             }
 
-            GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = PathComputationTest.graphSearch()
-                    .search(graph, srcV, dstV, weight, ALL_PATHS);
+            GraphPathSearch.Result<TopologyVertex, TopologyEdge> result =
+                    PathComputationTest.graphSearch()
+                            .search(graph, srcV, dstV, adapt(weight), ALL_PATHS);
             ImmutableSet.Builder<Path> builder = ImmutableSet.builder();
             for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
                 builder.add(PathComputationTest.networkPath(path));
@@ -1435,20 +1396,14 @@
         }
     }
 
-    private TopologyGraph getGraph(Set<TopologyVertex> removedVertex, Set<TopologyEdge> removedEdges) {
+    private TopologyGraph getGraph(Set<TopologyVertex> removedVertex,
+                                   Set<TopologyEdge> removedEdges) {
         if (removedVertex != null) {
-            vertexes.remove(removedVertex);
-            removedVertex.forEach(v ->
-            {
-                vertexes.remove(v);
-            });
+            removedVertex.forEach(vertexes::remove);
         }
 
         if (removedEdges != null) {
-            removedEdges.forEach(e ->
-            {
-                edges.remove(e);
-            });
+            removedEdges.forEach(edges::remove);
         }
 
         return new DefaultTopologyGraph(vertexes, edges);
@@ -1465,7 +1420,8 @@
 
             // Otherwise get all paths between the source and destination edge
             // devices.
-            computedPaths = topologyService.getPaths(null, (DeviceId) src, (DeviceId) dst, weight);
+            computedPaths = topologyService.getPaths(null, (DeviceId) src,
+                    (DeviceId) dst, weight);
             return computedPaths;
         }
 
@@ -1475,15 +1431,18 @@
     }
 
     private class MockTunnelServiceAdapter extends TunnelServiceAdapter {
-        private HashMap<TunnelId, Tunnel> tunnelIdAsKeyStore = new HashMap<TunnelId, Tunnel>();
+        private HashMap<TunnelId, Tunnel> tunnelIdAsKeyStore = new HashMap<>();
         private int tunnelIdCounter = 0;
 
         @Override
-        public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) {
+        public TunnelId setupTunnel(ApplicationId producerId,
+                                    ElementId srcElementId,
+                                    Tunnel tunnel, Path path) {
             TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter));
-            Tunnel tunnelToInsert = new DefaultTunnel(tunnel.providerId(), tunnel.src(), tunnel.dst(), tunnel.type(),
-                                                      tunnel.state(), tunnel.groupId(), tunnelId, tunnel.tunnelName(),
-                                                      path, tunnel.annotations());
+            Tunnel tunnelToInsert = new DefaultTunnel(tunnel.providerId(),
+                    tunnel.src(), tunnel.dst(), tunnel.type(),
+                    tunnel.state(), tunnel.groupId(), tunnelId,
+                    tunnel.tunnelName(), path, tunnel.annotations());
             tunnelIdAsKeyStore.put(tunnelId, tunnelToInsert);
             return tunnelId;
         }
@@ -1494,28 +1453,33 @@
         }
 
         /**
-         * Stimulates the effect of receiving PLSP id and LSP id from protocol PCRpt msg.
+         * Stimulates the effect of receiving PLSP id and LSP id from protocol
+         * PCRpt msg.
          */
-        public TunnelId updateTunnelWithLspIds(Tunnel tunnel, String pLspId, String localLspId, State state) {
+        public TunnelId updateTunnelWithLspIds(Tunnel tunnel, String pLspId,
+                                               String localLspId, State state) {
             TunnelId tunnelId = tunnel.tunnelId();
             Builder annotationBuilder = DefaultAnnotations.builder();
             annotationBuilder.putAll(tunnel.annotations());
 
-            // PCRpt in response to PCInitate msg will carry PLSP id allocated by PCC.
+            // PCRpt in response to PCInitate msg will carry PLSP id allocated
+            // by PCC.
             if (tunnel.annotations().value(PLSP_ID) == null) {
                 annotationBuilder.set(PLSP_ID, pLspId);
             }
 
-            // Signalled LSPs will carry local LSP id allocated by signalling protocol(PCC).
+            // Signalled LSPs will carry local LSP id allocated by signalling
+            // protocol(PCC).
             if (tunnel.annotations().value(LOCAL_LSP_ID) == null) {
                 annotationBuilder.set(LOCAL_LSP_ID, localLspId);
             }
             SparseAnnotations annotations = annotationBuilder.build();
             tunnelIdAsKeyStore.remove(tunnelId, tunnel);
 
-            Tunnel tunnelToInsert = new DefaultTunnel(tunnel.providerId(), tunnel.src(), tunnel.dst(), tunnel.type(),
-                                                      state, tunnel.groupId(), tunnelId, tunnel.tunnelName(),
-                                                      tunnel.path(), annotations);
+            Tunnel tunnelToInsert = new DefaultTunnel(tunnel.providerId(),
+                    tunnel.src(), tunnel.dst(), tunnel.type(),
+                    state, tunnel.groupId(), tunnelId, tunnel.tunnelName(),
+                    tunnel.path(), annotations);
 
             tunnelIdAsKeyStore.put(tunnelId, tunnelToInsert);
 
@@ -1544,40 +1508,45 @@
         }
 
         @Override
-        public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) {
-            Collection<Tunnel> result = new HashSet<Tunnel>();
+        public Collection<Tunnel> queryTunnel(TunnelEndPoint src,
+                                              TunnelEndPoint dst) {
+            Collection<Tunnel> result = new HashSet<>();
             Tunnel tunnel = null;
             for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
                 tunnel = tunnelIdAsKeyStore.get(tunnelId);
 
-                if ((null != tunnel) && (src.equals(tunnel.src())) && (dst.equals(tunnel.dst()))) {
+                if ((null != tunnel) && (src.equals(tunnel.src())) &&
+                        (dst.equals(tunnel.dst()))) {
                     result.add(tunnel);
                 }
             }
 
-            return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result);
+            return result.size() == 0 ? Collections.emptySet() :
+                    ImmutableSet.copyOf(result);
         }
 
         @Override
         public Collection<Tunnel> queryTunnel(Tunnel.Type type) {
-            Collection<Tunnel> result = new HashSet<Tunnel>();
+            Collection<Tunnel> result = new HashSet<>();
 
             for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
                 result.add(tunnelIdAsKeyStore.get(tunnelId));
             }
 
-            return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result);
+            return result.size() == 0 ? Collections.emptySet() :
+                    ImmutableSet.copyOf(result);
         }
 
         @Override
         public Collection<Tunnel> queryAllTunnels() {
-            Collection<Tunnel> result = new HashSet<Tunnel>();
+            Collection<Tunnel> result = new HashSet<>();
 
             for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
                 result.add(tunnelIdAsKeyStore.get(tunnelId));
             }
 
-            return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result);
+            return result.size() == 0 ? Collections.emptySet() :
+                    ImmutableSet.copyOf(result);
         }
 
         @Override
@@ -1586,7 +1555,8 @@
 
             for (Tunnel t : tunnelIdAsKeyStore.values()) {
                 for (Link l : t.path().links()) {
-                    if (l.src().deviceId().equals(deviceId) || l.dst().deviceId().equals(deviceId)) {
+                    if (l.src().deviceId().equals(deviceId) ||
+                            l.dst().deviceId().equals(deviceId)) {
                         tunnelList.add(t);
                         break;
                     }