[ONOS-4164] Failed path info store

Change-Id: I8e16493ce479d2489b16fc76b56f55455927cb56
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
index 8276f3d..9b90da0 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
@@ -17,6 +17,8 @@
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.collect.ImmutableSet;
+
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -30,15 +32,19 @@
 
 import org.onlab.util.KryoNamespace;
 import org.onosproject.incubator.net.tunnel.TunnelId;
+import org.onosproject.incubator.net.resource.label.LabelResource;
 import org.onosproject.incubator.net.resource.label.LabelResourceId;
 import org.onosproject.net.DeviceId;
+import org.onosproject.net.intent.Constraint;
 import org.onosproject.net.Link;
 import org.onosproject.net.resource.ResourceConsumer;
 import org.onosproject.pce.pceservice.TunnelConsumerId;
+import org.onosproject.pce.pceservice.LspType;
 import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
 import org.onosproject.pce.pcestore.api.PceStore;
 import org.onosproject.store.serializers.KryoNamespaces;
 import org.onosproject.store.service.ConsistentMap;
+import org.onosproject.store.service.DistributedSet;
 import org.onosproject.store.service.Serializer;
 import org.onosproject.store.service.StorageService;
 
@@ -53,11 +59,15 @@
 public class DistributedPceStore implements PceStore {
 
     private static final String DEVICE_ID_NULL = "Device ID cannot be null";
+    private static final String DEVICE_LABEL_STORE_INFO_NULL = "Device Label Store cannot be null";
+    private static final String LABEL_RESOURCE_ID_NULL = "Label Resource Id cannot be null";
+    private static final String LABEL_RESOURCE_LIST_NULL = "Label Resource List cannot be null";
+    private static final String LABEL_RESOURCE_NULL = "Label Resource cannot be null";
     private static final String LINK_NULL = "LINK cannot be null";
-    private static final String TUNNEL_ID_NULL = "Tunnel ID cannot be null";
-    private static final String LABEL_RESOURCE_ID_NULL = "Label Resource ID cannot be null";
+    private static final String LSP_LOCAL_LABEL_INFO_NULL = "LSP Local Label Info cannot be null";
+    private static final String PATH_INFO_NULL = "Path Info cannot be null";
     private static final String PCECC_TUNNEL_INFO_NULL = "PCECC Tunnel Info cannot be null";
-    private static final String LSP_LOCAL_LABEL_INFO_NULL = "LSP Local Label info cannot be null";
+    private static final String TUNNEL_ID_NULL = "Tunnel Id cannot be null";
     private static final String TUNNEL_CONSUMER_ID_NULL = "Tunnel consumer Id cannot be null";
 
     private final Logger log = LoggerFactory.getLogger(getClass());
@@ -74,6 +84,9 @@
     // Mapping tunnel with device local info with tunnel consumer id
     private ConsistentMap<TunnelId, PceccTunnelInfo> tunnelInfoMap;
 
+    // List of Failed path info
+    private DistributedSet<PcePathInfo> failedPathSet;
+
     @Activate
     protected void activate() {
         globalNodeLabelMap = storageService.<DeviceId, LabelResourceId>consistentMapBuilder()
@@ -91,6 +104,7 @@
                         new KryoNamespace.Builder()
                                 .register(KryoNamespaces.API)
                                 .register(Link.class,
+                                          LabelResource.class,
                                           LabelResourceId.class)
                                 .build()))
                 .build();
@@ -108,6 +122,22 @@
                                 .build()))
                 .build();
 
+        failedPathSet = storageService.<PcePathInfo>setBuilder()
+                .withName("failed-path-info")
+                .withSerializer(Serializer.using(
+                        new KryoNamespace.Builder()
+                                .register(KryoNamespaces.API)
+                                .register(PcePathInfo.class,
+                                          //TODO: Instead of Constraint.class need to add actual implemented class
+                                          //TODO: on this interface like CostConstraint.class and
+                                          //TODO: BandwidthConstraint.class. Will be added once it is confirmed.
+                                          Constraint.class,
+                                          LspType.class)
+                                .build()))
+
+                .build()
+                .asDistributedSet();
+
         log.info("Started");
     }
 
@@ -135,6 +165,12 @@
     }
 
     @Override
+    public boolean existsFailedPathInfo(PcePathInfo failedPathInfo) {
+        checkNotNull(failedPathInfo, PATH_INFO_NULL);
+        return failedPathSet.contains(failedPathInfo);
+    }
+
+    @Override
     public int getGlobalNodeLabelCount() {
         return globalNodeLabelMap.size();
     }
@@ -150,6 +186,11 @@
     }
 
     @Override
+    public int getFailedPathInfoCount() {
+        return failedPathSet.size();
+    }
+
+    @Override
     public Map<DeviceId, LabelResourceId> getGlobalNodeLabels() {
        return globalNodeLabelMap.entrySet().stream()
                  .collect(Collectors.toMap(Map.Entry::getKey, e -> (LabelResourceId) e.getValue().value()));
@@ -168,6 +209,11 @@
     }
 
     @Override
+    public Iterable<PcePathInfo> getFailedPathInfos() {
+       return ImmutableSet.copyOf(failedPathSet);
+    }
+
+    @Override
     public LabelResourceId getGlobalNodeLabel(DeviceId id) {
         checkNotNull(id, DEVICE_ID_NULL);
         return globalNodeLabelMap.get(id).value();
@@ -210,6 +256,12 @@
     }
 
     @Override
+    public void addFailedPathInfo(PcePathInfo failedPathInfo) {
+        checkNotNull(failedPathInfo, PATH_INFO_NULL);
+        failedPathSet.add(failedPathInfo);
+    }
+
+    @Override
     public boolean updateTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList) {
         checkNotNull(tunnelId, TUNNEL_ID_NULL);
         checkNotNull(lspLocalLabelInfoList, LSP_LOCAL_LABEL_INFO_NULL);
@@ -275,4 +327,15 @@
         }
         return true;
     }
+
+    @Override
+    public boolean removeFailedPathInfo(PcePathInfo failedPathInfo) {
+        checkNotNull(failedPathInfo, PATH_INFO_NULL);
+
+        if (!failedPathSet.remove(failedPathInfo)) {
+            log.error("Failed path info {} deletion has failed.", failedPathInfo.toString());
+            return false;
+        }
+        return true;
+    }
 }
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/PcePathInfo.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/PcePathInfo.java
new file mode 100644
index 0000000..3b7b47e
--- /dev/null
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/PcePathInfo.java
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.pcestore;
+
+import com.google.common.base.MoreObjects;
+
+import java.util.List;
+import java.util.Objects;
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.intent.Constraint;
+import org.onosproject.pce.pceservice.LspType;
+
+/**
+ * Input path information to compute CSPF path.
+ * This path information will be stored in pce store and will be used later to recalculate the path.
+ */
+public final class PcePathInfo {
+
+    private DeviceId src; // source path
+
+    private DeviceId dst; // destination path
+
+    private String name; // tunnel name
+
+    private List<Constraint> constraints; // list of constraints (cost, bandwidth, etc.)
+
+    private LspType lspType; // lsp type
+
+    /**
+     * Initialization of member variables.
+     *
+     * @param src source device id
+     * @param dst destination device id
+     * @param name tunnel name
+     * @param constraints list of constraints
+     * @param lspType lsp type
+     */
+    public PcePathInfo(DeviceId src,
+                    DeviceId dst,
+                    String name,
+                    List<Constraint> constraints,
+                    LspType lspType) {
+       this.src = src;
+       this.dst = dst;
+       this.name = name;
+       this.constraints = constraints;
+       this.lspType = lspType;
+    }
+
+    /**
+     * Initialization for serialization.
+     */
+    public PcePathInfo() {
+       this.src = null;
+       this.dst = null;
+       this.name = null;
+       this.constraints = null;
+       this.lspType = null;
+    }
+
+    /**
+     * Returns source device id.
+     *
+     * @return source device id
+     */
+    public DeviceId src() {
+       return src;
+    }
+
+    /**
+     * Sets source device id.
+     *
+     * @param id source device id
+     */
+    public void src(DeviceId id) {
+        this.src = id;
+    }
+
+    /**
+     * Returns destination device id.
+     *
+     * @return destination device id
+     */
+    public DeviceId dst() {
+       return dst;
+    }
+
+    /**
+     * Sets destination device id.
+     *
+     * @param id destination device id
+     */
+    public void dst(DeviceId id) {
+        this.dst = id;
+    }
+
+
+    /**
+     * Returns tunnel name.
+     *
+     * @return name
+     */
+    public String name() {
+       return name;
+    }
+
+    /**
+     * Sets tunnel name.
+     *
+     * @param name tunnel name
+     */
+    public void name(String name) {
+        this.name = name;
+    }
+
+    /**
+     * Returns list of constraints including cost, bandwidth, etc.
+     *
+     * @return list of constraints
+     */
+    public List<Constraint> constraints() {
+       return constraints;
+    }
+
+    /**
+     * Sets list of constraints.
+     * @param constraints list of constraints
+     */
+    public void constraints(List<Constraint> constraints) {
+        this.constraints = constraints;
+    }
+
+    /**
+     * Returns lsp type.
+     *
+     * @return lsp type
+     */
+    public LspType lspType() {
+       return lspType;
+    }
+
+    /**
+     * Sets lsp type.
+     *
+     * @param lspType lsp type
+     */
+    public void lspType(LspType lspType) {
+        this.lspType = lspType;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(src, dst, name, constraints, lspType);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof PcePathInfo) {
+            final PcePathInfo other = (PcePathInfo) obj;
+            return Objects.equals(this.src, other.src) &&
+                    Objects.equals(this.dst, other.dst) &&
+                    Objects.equals(this.name, other.name) &&
+                    Objects.equals(this.constraints, other.constraints) &&
+                    Objects.equals(this.lspType, other.lspType);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .omitNullValues()
+                .add("Source", src.toString())
+                .add("Destination", dst.toString())
+                .add("Name", name.toString())
+                .add("Constraints", constraints.toString())
+                .add("LspType", lspType.toString())
+                .toString();
+    }
+}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java
index 912330c..02ffcf6 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java
@@ -23,6 +23,7 @@
 import org.onosproject.net.Link;
 import org.onosproject.net.resource.ResourceConsumer;
 import org.onosproject.pce.pcestore.PceccTunnelInfo;
+import org.onosproject.pce.pcestore.PcePathInfo;
 
 import java.util.Map;
 
@@ -55,6 +56,14 @@
     boolean existsTunnelInfo(TunnelId tunnelId);
 
     /**
+     * Checks whether path info is present in failed path info list.
+     *
+     * @param failedPathInfo failed path information
+     * @return success or failure
+     */
+    boolean existsFailedPathInfo(PcePathInfo failedPathInfo);
+
+    /**
      * Retrieves the node label count.
      *
      * @return node label count
@@ -76,6 +85,13 @@
     int getTunnelInfoCount();
 
     /**
+     * Retrieves the failed path info count.
+     *
+     * @return failed path info count
+     */
+    int getFailedPathInfoCount();
+
+    /**
      * Retrieves device id and label pairs collection from global node label store.
      *
      * @return collection of device id and label pairs
@@ -97,6 +113,13 @@
     Map<TunnelId, PceccTunnelInfo> getTunnelInfos();
 
     /**
+     * Retrieves path info collection from failed path info store.
+     *
+     * @return collection of failed path info
+     */
+    Iterable<PcePathInfo> getFailedPathInfos();
+
+    /**
      * Retrieves node label for specified device id.
      *
      * @param id device id
@@ -145,6 +168,13 @@
     void addTunnelInfo(TunnelId tunnelId, PceccTunnelInfo pceccTunnelInfo);
 
     /**
+     * Stores path information into failed path info store.
+     *
+     * @param failedPathInfo failed path information
+     */
+    void addFailedPathInfo(PcePathInfo failedPathInfo);
+
+    /**
      * Updates local label info. The first entry is created with TunnelId and TunnelConsumerId.
      * Later this entry may be updated to store label information if it is basic PCECC case.
      *
@@ -186,4 +216,12 @@
      * @return success or failure
      */
     boolean removeTunnelInfo(TunnelId tunnelId);
+
+    /**
+     * Removes path info from failed path info store.
+     *
+     * @param failedPathInfo failed path information
+     * @return success or failure
+     */
+    boolean removeFailedPathInfo(PcePathInfo failedPathInfo);
 }
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DistributedPceStoreTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DistributedPceStoreTest.java
index a64db83..e1ca650 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DistributedPceStoreTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DistributedPceStoreTest.java
@@ -29,6 +29,7 @@
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import org.onlab.util.DataRateUnit;
 import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
 import org.onosproject.incubator.net.resource.label.LabelResource;
 import org.onosproject.incubator.net.resource.label.LabelResourceId;
@@ -38,9 +39,12 @@
 import org.onosproject.net.DefaultLink;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.ElementId;
+import org.onosproject.net.intent.Constraint;
+import org.onosproject.net.intent.constraint.BandwidthConstraint;
 import org.onosproject.net.Link;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.resource.ResourceConsumer;
+import org.onosproject.pce.pceservice.LspType;
 import org.onosproject.pce.pceservice.TunnelConsumerId;
 import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
 import org.onosproject.net.provider.ProviderId;
@@ -82,6 +86,10 @@
     private TunnelId tunnelId4 = TunnelId.valueOf("4");
     private PceccTunnelInfo pceccTunnelInfo1;
     private PceccTunnelInfo pceccTunnelInfo2;
+    private PcePathInfo failedPathInfo1;
+    private PcePathInfo failedPathInfo2;
+    private PcePathInfo failedPathInfo3;
+    private PcePathInfo failedPathInfo4;
 
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
@@ -150,6 +158,50 @@
        lspLocalLabelInfoList2.add(lspLocalLabel2);
 
        pceccTunnelInfo2 = new PceccTunnelInfo(lspLocalLabelInfoList2, tunnelConsumerId2);
+
+       // Creates failedPathInfo1
+       DeviceId src1 = DeviceId.deviceId("foo1");
+       DeviceId dst1 = DeviceId.deviceId("goo1");
+       String name1 = "pcc1";
+       LspType lspType1 = LspType.SR_WITHOUT_SIGNALLING;
+       List<Constraint> constraints1 = new LinkedList<>();
+       Constraint bandwidth1 = BandwidthConstraint.of(200, DataRateUnit.BPS);
+       constraints1.add(bandwidth1);
+
+       failedPathInfo1 = new PcePathInfo(src1, dst1, name1, constraints1, lspType1);
+
+       // Creates failedPathInfo2
+       DeviceId src2 = DeviceId.deviceId("foo2");
+       DeviceId dst2 = DeviceId.deviceId("goo2");
+       String name2 = "pcc2";
+       LspType lspType2 = LspType.SR_WITHOUT_SIGNALLING;
+       List<Constraint> constraints2 = new LinkedList<>();
+       Constraint bandwidth2 = BandwidthConstraint.of(400, DataRateUnit.BPS);
+       constraints2.add(bandwidth2);
+
+       failedPathInfo2 = new PcePathInfo(src2, dst2, name2, constraints2, lspType2);
+
+       // Creates failedPathInfo3
+       DeviceId src3 = DeviceId.deviceId("foo3");
+       DeviceId dst3 = DeviceId.deviceId("goo3");
+       String name3 = "pcc3";
+       LspType lspType3 = LspType.SR_WITHOUT_SIGNALLING;
+       List<Constraint> constraints3 = new LinkedList<>();
+       Constraint bandwidth3 = BandwidthConstraint.of(500, DataRateUnit.BPS);
+       constraints3.add(bandwidth3);
+
+       failedPathInfo3 = new PcePathInfo(src3, dst3, name3, constraints3, lspType3);
+
+       // Creates failedPathInfo4
+       DeviceId src4 = DeviceId.deviceId("foo4");
+       DeviceId dst4 = DeviceId.deviceId("goo4");
+       String name4 = "pcc4";
+       LspType lspType4 = LspType.SR_WITHOUT_SIGNALLING;
+       List<Constraint> constraints4 = new LinkedList<>();
+       Constraint bandwidth4 = BandwidthConstraint.of(600, DataRateUnit.BPS);
+       constraints4.add(bandwidth4);
+
+       failedPathInfo4 = new PcePathInfo(src4, dst4, name4, constraints4, lspType4);
     }
 
     @After
@@ -211,6 +263,22 @@
     }
 
     /**
+     * Checks the operation of addFailedPathInfo() method.
+     */
+    @Test
+    public void testAddFailedPathInfo() {
+        // initialization
+        distrPceStore.storageService = new TestStorageService();
+        distrPceStore.activate();
+
+        // PcePathInfo with pce path input information
+        distrPceStore.addFailedPathInfo(failedPathInfo1);
+        assertThat(distrPceStore.existsFailedPathInfo(failedPathInfo1), is(true));
+        distrPceStore.addFailedPathInfo(failedPathInfo2);
+        assertThat(distrPceStore.existsFailedPathInfo(failedPathInfo2), is(true));
+    }
+
+    /**
      * Checks the operation of existsGlobalNodeLabel() method.
      */
     @Test
@@ -248,6 +316,19 @@
     }
 
     /**
+     * Checks the operation of existsFailedPathInfo() method.
+     */
+    @Test
+    public void testExistsFailedPathInfo() {
+        testAddFailedPathInfo();
+
+        assertThat(distrPceStore.existsFailedPathInfo(failedPathInfo1), is(true));
+        assertThat(distrPceStore.existsFailedPathInfo(failedPathInfo2), is(true));
+        assertThat(distrPceStore.existsFailedPathInfo(failedPathInfo3), is(false));
+        assertThat(distrPceStore.existsFailedPathInfo(failedPathInfo4), is(false));
+    }
+
+    /**
      * Checks the operation of getGlobalNodeLabelCount() method.
      */
     @Test
@@ -278,6 +359,16 @@
     }
 
     /**
+     * Checks the operation of getFailedPathInfoCount() method.
+     */
+    @Test
+    public void testGetFailedPathInfoCount() {
+        testAddFailedPathInfo();
+
+        assertThat(distrPceStore.getFailedPathInfoCount(), is(2));
+    }
+
+    /**
      * Checks the operation of getGlobalNodeLabels() method.
      */
     @Test
@@ -317,6 +408,18 @@
     }
 
     /**
+     * Checks the operation of getFailedPathInfos() method.
+     */
+    @Test
+    public void testGetFailedPathInfos() {
+        testAddFailedPathInfo();
+
+        Iterable<PcePathInfo> failedPathInfoSet = distrPceStore.getFailedPathInfos();
+        assertThat(failedPathInfoSet, is(notNullValue()));
+        assertThat(failedPathInfoSet.iterator().hasNext(), is(true));
+    }
+
+    /**
      * Checks the operation of getGlobalNodeLabel() method.
      */
     @Test
@@ -451,4 +554,17 @@
         assertThat(distrPceStore.removeTunnelInfo(tunnelId1), is(true));
         assertThat(distrPceStore.removeTunnelInfo(tunnelId2), is(true));
     }
+
+    /**
+     * Checks the operation of removeFailedPathInfo() method.
+     */
+    @Test
+    public void testRemoveFailedPathInfo() {
+        testAddFailedPathInfo();
+
+        assertThat(distrPceStore.removeFailedPathInfo(failedPathInfo1), is(true));
+        assertThat(distrPceStore.removeFailedPathInfo(failedPathInfo2), is(true));
+        assertThat(distrPceStore.removeFailedPathInfo(failedPathInfo3), is(false));
+        assertThat(distrPceStore.removeFailedPathInfo(failedPathInfo4), is(false));
+    }
 }
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/PcePathInfoTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/PcePathInfoTest.java
new file mode 100644
index 0000000..09b60ab
--- /dev/null
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/PcePathInfoTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.pcestore;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+import com.google.common.testing.EqualsTester;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import org.junit.Test;
+import org.onlab.util.DataRateUnit;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.intent.Constraint;
+import org.onosproject.net.intent.constraint.BandwidthConstraint;
+import org.onosproject.pce.pceservice.LspType;
+
+/**
+ * Unit tests for PcePathInfo class.
+ */
+public class PcePathInfoTest {
+
+    /**
+     * Checks the operation of equals() methods.
+     */
+    @Test
+    public void testEquals() {
+        // create same two objects.
+        DeviceId src1 = DeviceId.deviceId("foo1");
+        DeviceId dst1 = DeviceId.deviceId("goo1");
+        String name1 = "pcc1";
+        LspType lspType1 = LspType.WITH_SIGNALLING;
+        List<Constraint> constraints1 = new LinkedList<>();
+        Constraint bandwidth11 = BandwidthConstraint.of(100, DataRateUnit.BPS);
+        constraints1.add(bandwidth11);
+        Constraint bandwidth12 = BandwidthConstraint.of(200, DataRateUnit.BPS);
+        constraints1.add(bandwidth12);
+        Constraint bandwidth13 = BandwidthConstraint.of(300, DataRateUnit.BPS);
+        constraints1.add(bandwidth13);
+
+        PcePathInfo pathInfo1 = new PcePathInfo(src1, dst1, name1, constraints1, lspType1);
+
+        // create same object as above object
+        PcePathInfo samePathInfo1 = new PcePathInfo(src1, dst1, name1, constraints1, lspType1);
+
+        // Create different object.
+        DeviceId src2 = DeviceId.deviceId("foo2");
+        DeviceId dst2 = DeviceId.deviceId("goo2");
+        String name2 = "pcc2";
+        LspType lspType2 = LspType.SR_WITHOUT_SIGNALLING;
+        List<Constraint> constraints2 = new LinkedList<>();
+        Constraint bandwidth21 = BandwidthConstraint.of(400, DataRateUnit.BPS);
+        constraints2.add(bandwidth21);
+        Constraint bandwidth22 = BandwidthConstraint.of(800, DataRateUnit.BPS);
+        constraints2.add(bandwidth22);
+
+        PcePathInfo pathInfo2 = new PcePathInfo(src2, dst2, name2, constraints2, lspType2);
+
+        new EqualsTester().addEqualityGroup(pathInfo1, samePathInfo1)
+                          .addEqualityGroup(pathInfo2)
+                          .testEquals();
+    }
+
+    /**
+     * Checks the construction of a PcePathInfo object.
+     */
+    @Test
+    public void testConstruction() {
+        DeviceId src = DeviceId.deviceId("foo2");
+        DeviceId dst = DeviceId.deviceId("goo2");
+        String name = "pcc2";
+        LspType lspType = LspType.SR_WITHOUT_SIGNALLING;
+        List<Constraint> constraints = new LinkedList<>();
+        Constraint bandwidth1 = BandwidthConstraint.of(100, DataRateUnit.BPS);
+        constraints.add(bandwidth1);
+        Constraint bandwidth2 = BandwidthConstraint.of(200, DataRateUnit.BPS);
+        constraints.add(bandwidth2);
+        Constraint bandwidth3 = BandwidthConstraint.of(300, DataRateUnit.BPS);
+        constraints.add(bandwidth3);
+
+        PcePathInfo pathInfo = new PcePathInfo(src, dst, name, constraints, lspType);
+
+        assertThat(src, is(pathInfo.src()));
+        assertThat(dst, is(pathInfo.dst()));
+        assertThat(name, is(pathInfo.name()));
+        assertThat(constraints, is(pathInfo.constraints()));
+        assertThat(lspType, is(pathInfo.lspType()));
+    }
+}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/util/PceStoreAdapter.java b/apps/pce/app/src/test/java/org/onosproject/pce/util/PceStoreAdapter.java
new file mode 100644
index 0000000..beaf8ae
--- /dev/null
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/util/PceStoreAdapter.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.util;
+
+import com.google.common.collect.ImmutableSet;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.onosproject.incubator.net.resource.label.LabelResourceId;
+import org.onosproject.incubator.net.tunnel.TunnelId;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Link;
+import org.onosproject.net.resource.ResourceConsumer;
+import org.onosproject.pce.pcestore.PceccTunnelInfo;
+import org.onosproject.pce.pcestore.PcePathInfo;
+import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
+import org.onosproject.pce.pcestore.api.PceStore;
+
+/**
+ * Provides test implementation of PceStore.
+ */
+public class PceStoreAdapter implements PceStore {
+
+    // Mapping device with global node label
+    private ConcurrentMap<DeviceId, LabelResourceId> globalNodeLabelMap = new ConcurrentHashMap<>();
+
+    // Mapping link with adjacency label
+    private ConcurrentMap<Link, LabelResourceId> adjLabelMap = new ConcurrentHashMap<>();
+
+    // Mapping tunnel with device local info with tunnel consumer id
+    private ConcurrentMap<TunnelId, PceccTunnelInfo> tunnelInfoMap = new ConcurrentHashMap<>();
+
+    // Set of Path info
+    private Set<PcePathInfo> failedPathInfoSet = new HashSet<>();
+
+    @Override
+    public boolean existsGlobalNodeLabel(DeviceId id) {
+        return globalNodeLabelMap.containsKey(id);
+    }
+
+    @Override
+    public boolean existsAdjLabel(Link link) {
+        return adjLabelMap.containsKey(link);
+    }
+
+    @Override
+    public boolean existsTunnelInfo(TunnelId tunnelId) {
+        return tunnelInfoMap.containsKey(tunnelId);
+    }
+
+    @Override
+    public boolean existsFailedPathInfo(PcePathInfo pathInfo) {
+        return failedPathInfoSet.contains(pathInfo);
+    }
+
+    @Override
+    public int getGlobalNodeLabelCount() {
+        return globalNodeLabelMap.size();
+    }
+
+    @Override
+    public int getAdjLabelCount() {
+        return adjLabelMap.size();
+    }
+
+    @Override
+    public int getTunnelInfoCount() {
+        return tunnelInfoMap.size();
+    }
+
+    @Override
+    public int getFailedPathInfoCount() {
+        return failedPathInfoSet.size();
+    }
+
+    @Override
+    public Map<DeviceId, LabelResourceId> getGlobalNodeLabels() {
+       return globalNodeLabelMap.entrySet().stream()
+                 .collect(Collectors.toMap(Map.Entry::getKey, e -> (LabelResourceId) e.getValue()));
+    }
+
+    @Override
+    public Map<Link, LabelResourceId> getAdjLabels() {
+       return adjLabelMap.entrySet().stream()
+                 .collect(Collectors.toMap(Map.Entry::getKey, e -> (LabelResourceId) e.getValue()));
+    }
+
+    @Override
+    public Map<TunnelId, PceccTunnelInfo> getTunnelInfos() {
+       return tunnelInfoMap.entrySet().stream()
+                 .collect(Collectors.toMap(Map.Entry::getKey, e -> (PceccTunnelInfo) e.getValue()));
+    }
+
+    @Override
+    public Iterable<PcePathInfo> getFailedPathInfos() {
+       return ImmutableSet.copyOf(failedPathInfoSet);
+    }
+
+    @Override
+    public LabelResourceId getGlobalNodeLabel(DeviceId id) {
+        return globalNodeLabelMap.get(id);
+    }
+
+    @Override
+    public LabelResourceId getAdjLabel(Link link) {
+        return adjLabelMap.get(link);
+    }
+
+    @Override
+    public PceccTunnelInfo getTunnelInfo(TunnelId tunnelId) {
+        return tunnelInfoMap.get(tunnelId);
+    }
+
+    @Override
+    public void addGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId) {
+        globalNodeLabelMap.put(deviceId, labelId);
+    }
+
+    @Override
+    public void addAdjLabel(Link link, LabelResourceId labelId) {
+        adjLabelMap.put(link, labelId);
+    }
+
+    @Override
+    public void addTunnelInfo(TunnelId tunnelId, PceccTunnelInfo pceccTunnelInfo) {
+        tunnelInfoMap.put(tunnelId, pceccTunnelInfo);
+    }
+
+    @Override
+    public void addFailedPathInfo(PcePathInfo pathInfo) {
+        failedPathInfoSet.add(pathInfo);
+    }
+
+    @Override
+    public boolean updateTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList) {
+        if (!tunnelInfoMap.containsKey((tunnelId))) {
+            return false;
+        }
+
+        PceccTunnelInfo labelStoreInfo = tunnelInfoMap.get(tunnelId);
+        labelStoreInfo.lspLocalLabelInfoList(lspLocalLabelInfoList);
+        tunnelInfoMap.put(tunnelId, labelStoreInfo);
+        return true;
+    }
+
+    @Override
+    public boolean updateTunnelInfo(TunnelId tunnelId, ResourceConsumer tunnelConsumerId) {
+        if (!tunnelInfoMap.containsKey((tunnelId))) {
+            return false;
+        }
+
+        PceccTunnelInfo tunnelInfo = tunnelInfoMap.get(tunnelId);
+        tunnelInfo.tunnelConsumerId(tunnelConsumerId);
+        tunnelInfoMap.put(tunnelId, tunnelInfo);
+        return true;
+    }
+
+    @Override
+    public boolean removeGlobalNodeLabel(DeviceId id) {
+        globalNodeLabelMap.remove(id);
+        if (globalNodeLabelMap.containsKey(id)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public boolean removeAdjLabel(Link link) {
+        adjLabelMap.remove(link);
+        if (adjLabelMap.containsKey(link)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public boolean removeTunnelInfo(TunnelId tunnelId) {
+        tunnelInfoMap.remove(tunnelId);
+        if (tunnelInfoMap.containsKey(tunnelId)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public boolean removeFailedPathInfo(PcePathInfo pathInfo) {
+        if (failedPathInfoSet.remove(pathInfo)) {
+            return false;
+        }
+        return true;
+    }
+}