Add unit tests for ClusterMetadata

- fix a typo
Change-Id: I13f615857b82ef5bf69b437ffb8b9f82d3d7c48e
diff --git a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataTest.java b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataTest.java
new file mode 100644
index 0000000..4ea190c
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataTest.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2017-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.cluster;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.provider.ProviderId;
+
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.*;
+
+/**
+ * Unit tests for ClusterMetadata.
+ */
+public class ClusterMetadataTest {
+    private final PartitionId pid1 = PartitionId.from(1);
+    private final PartitionId pid2 = PartitionId.from(2);
+
+    private final NodeId nid1 = NodeId.nodeId("10.0.0.1");
+    private final NodeId nid2 = NodeId.nodeId("10.0.0.2");
+
+    private final ControllerNode n1 =
+            new DefaultControllerNode(nid1, IpAddress.valueOf("10.0.0.1"), 9876);
+    private final ControllerNode n2 =
+            new DefaultControllerNode(nid2, IpAddress.valueOf("10.0.0.2"), 9876);
+
+    private final Partition p1 = new DefaultPartition(pid1, ImmutableSet.of(nid1));
+    private final Partition p2 = new DefaultPartition(pid2, ImmutableSet.of(nid1, nid2));
+
+    private final ClusterMetadata metadata1 =
+            new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
+    private final ClusterMetadata sameAsMetadata1 =
+            new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
+    private final ClusterMetadata metadata2 =
+            new ClusterMetadata("bar", ImmutableSet.of(n1, n2), ImmutableSet.of(p1, p2));
+    private final ProviderId defaultProvider =
+            new ProviderId("none", "none");
+    /**
+     * Tests for proper operation of equals(), hashCode() and toString() methods.
+     */
+    @Test
+    public void checkEquals() {
+        new EqualsTester()
+                .addEqualityGroup(metadata1, sameAsMetadata1)
+                .addEqualityGroup(metadata2)
+                .testEquals();
+    }
+
+    /**
+     * Tests that objects are created properly and accessor methods return
+     * the correct values.
+     */
+    @Test
+    public void checkConstruction() {
+        assertThat(metadata2.getName(), is("bar"));
+        assertThat(metadata2.getNodes(), hasSize(2));
+        assertThat(metadata2.getNodes(), contains(n1, n2));
+        assertThat(metadata2.getPartitions(), hasSize(2));
+        assertThat(metadata2.getPartitions(), contains(p1, p2));
+        assertThat(metadata1.providerId(), is(defaultProvider));
+
+    }
+}
diff --git a/core/api/src/test/java/org/onosproject/cluster/LeadershipTest.java b/core/api/src/test/java/org/onosproject/cluster/LeadershipTest.java
index 04d917a..928b183 100644
--- a/core/api/src/test/java/org/onosproject/cluster/LeadershipTest.java
+++ b/core/api/src/test/java/org/onosproject/cluster/LeadershipTest.java
@@ -59,7 +59,7 @@
 
     /**
      * Tests that objects are created properly and accessor methods return
-     * the correct vsalues.
+     * the correct values.
      */
     @Test
     public void checkConstruction() {