Improve core API coverage with new unit tests

- DefaultMirroringDescription
- MirroringName
- MirroringStatistics
- QosId
- made classes immutable

Change-Id: I1d1bf983b181ca87afc35565c5e614f4c54fe0fc
diff --git a/core/api/src/test/java/org/onosproject/net/behaviour/DefaultMirroringDescriptionTest.java b/core/api/src/test/java/org/onosproject/net/behaviour/DefaultMirroringDescriptionTest.java
new file mode 100644
index 0000000..2596f7b
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/behaviour/DefaultMirroringDescriptionTest.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.net.behaviour;
+
+import java.util.List;
+import java.util.Optional;
+
+import org.junit.Test;
+import org.onlab.packet.VlanId;
+
+import com.google.common.collect.ImmutableList;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+public class DefaultMirroringDescriptionTest {
+
+    private static final MirroringName NAME_1 = MirroringName.mirroringName("mirror1");
+    private static final List<String> MONITOR_SRC_PORTS_1 =
+            ImmutableList.of("s1", "s2", "s3");
+    private static final List<String> MONITOR_DST_PORTS_1 =
+            ImmutableList.of("d1", "d2");
+    private static final List<VlanId> MONITOR_VLANS_1 = ImmutableList.of(VlanId.ANY);
+    private static final Optional<String> MIRROR_PORT_1 = Optional.of("port1");
+    private static final Optional<VlanId> MIRROR_VLAN_1 = Optional.of(VlanId.ANY);
+    private MirroringDescription md1 =
+            new DefaultMirroringDescription(NAME_1, MONITOR_SRC_PORTS_1,
+                                            MONITOR_DST_PORTS_1, MONITOR_VLANS_1,
+                                            MIRROR_PORT_1, MIRROR_VLAN_1);
+
+
+    @Test
+    public void testImmutability() {
+        assertThatClassIsImmutable(DefaultMirroringDescription.class);
+    }
+
+    @Test
+    public void testConstruction() {
+        assertThat(md1.name(), is(NAME_1));
+        assertThat(md1.monitorSrcPorts(), is(MONITOR_SRC_PORTS_1));
+        assertThat(md1.monitorDstPorts(), is(MONITOR_DST_PORTS_1));
+        assertThat(md1.monitorVlans(), is(MONITOR_VLANS_1));
+        assertThat(md1.mirrorPort(), is(MIRROR_PORT_1));
+        assertThat(md1.mirrorVlan(), is(MIRROR_VLAN_1));
+    }
+
+    @Test
+    public void testToString() {
+        String result = md1.toString();
+        assertThat(result, notNullValue());
+        assertThat(result, containsString("name=" + NAME_1.toString()));
+        assertThat(result, containsString("monitorsrcports=" + MONITOR_SRC_PORTS_1.toString()));
+        assertThat(result, containsString("monitordstports=" + MONITOR_DST_PORTS_1.toString()));
+        assertThat(result, containsString("monitorvlans=" + MONITOR_VLANS_1.toString()));
+        assertThat(result, containsString("mirrorport=" + MIRROR_PORT_1.toString()));
+        assertThat(result, containsString("mirrorvlan=" + MIRROR_VLAN_1.toString()));
+    }
+}
diff --git a/core/api/src/test/java/org/onosproject/net/behaviour/MirroringNameTest.java b/core/api/src/test/java/org/onosproject/net/behaviour/MirroringNameTest.java
new file mode 100644
index 0000000..bce584f
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/behaviour/MirroringNameTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.net.behaviour;
+
+import org.junit.Test;
+
+import com.google.common.testing.EqualsTester;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+public class MirroringNameTest {
+
+    private static final String NAME1 = "name1";
+    private MirroringName name1 = MirroringName.mirroringName(NAME1);
+    private MirroringName sameAsName1 = MirroringName.mirroringName(NAME1);
+    private static final String NAME2 = "name2";
+    private MirroringName name2 = MirroringName.mirroringName(NAME2);
+
+    @Test
+    public void testImmutability() {
+        assertThatClassIsImmutable(MirroringName.class);
+    }
+
+    @Test
+    public void testConstruction() {
+        assertThat(name1.name(), is(NAME1));
+    }
+
+    @Test
+    public void testEquals() {
+        new EqualsTester()
+                .addEqualityGroup(name1, sameAsName1)
+                .addEqualityGroup(name2)
+                .testEquals();
+    }
+}
diff --git a/core/api/src/test/java/org/onosproject/net/behaviour/MirroringStatisticsTest.java b/core/api/src/test/java/org/onosproject/net/behaviour/MirroringStatisticsTest.java
new file mode 100644
index 0000000..b79da88
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/behaviour/MirroringStatisticsTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.net.behaviour;
+
+import java.util.Map;
+
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.testing.EqualsTester;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+public class MirroringStatisticsTest {
+
+    private static final long BYTES_1 = 100L;
+    private static final long PACKETS_1 = 2L;
+    private static final String NAME_1 = "mirror1";
+    private Map<String, Integer> statistics1 =
+            ImmutableMap.of("tx_bytes", (int) BYTES_1, "tx_packets", (int) PACKETS_1);
+    private MirroringStatistics mirrorStatisticStats1 = MirroringStatistics.mirroringStatistics(NAME_1, statistics1);
+
+    private Map<String, Integer> sameAsStatistics1 =
+            ImmutableMap.of("tx_bytes", (int) BYTES_1, "tx_packets", (int) PACKETS_1);
+    private MirroringStatistics sameAsMirrorStatisticStats1 =
+            MirroringStatistics.mirroringStatistics(NAME_1, sameAsStatistics1);
+
+    private static final long BYTES_2 = 100L;
+    private static final long PACKETS_2 = 2L;
+    private static final String NAME_2 = "mirror2";
+    private Map<String, Integer> statistics2 =
+            ImmutableMap.of("tx_bytes", (int) BYTES_2, "tx_packets", (int) PACKETS_2);
+    private MirroringStatistics mirrorStatisticStats2 = MirroringStatistics.mirroringStatistics(NAME_2, statistics2);
+
+    private static final long BYTES_3 = 100L;
+    private static final long PACKETS_3 = 2L;
+    private static final String NAME_3 = "mirror3";
+    private Map<String, Integer> statistics3 =
+            ImmutableMap.of("tx_bytes", (int) BYTES_3, "tx_packets", (int) PACKETS_3);
+    private MirroringStatistics mirrorStatisticStats3 = MirroringStatistics.mirroringStatistics(NAME_3, statistics3);
+
+    @Test
+    public void testImmutability() {
+        assertThatClassIsImmutable(MirroringStatistics.class);
+    }
+
+    @Test
+    public void testConstruction() {
+        assertThat(mirrorStatisticStats1.bytes(), is(BYTES_1));
+        assertThat(mirrorStatisticStats1.name().name(), is(NAME_1));
+        assertThat(mirrorStatisticStats1.packets(), is(PACKETS_1));
+    }
+
+    @Test
+    public void testEquals() {
+        new EqualsTester()
+                .addEqualityGroup(mirrorStatisticStats1, sameAsMirrorStatisticStats1)
+                .addEqualityGroup(mirrorStatisticStats2)
+                .addEqualityGroup(mirrorStatisticStats3)
+                .testEquals();
+    }
+}
diff --git a/core/api/src/test/java/org/onosproject/net/behaviour/QosIdTest.java b/core/api/src/test/java/org/onosproject/net/behaviour/QosIdTest.java
new file mode 100644
index 0000000..11f5c40
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/behaviour/QosIdTest.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.net.behaviour;
+
+public class QosIdTest {
+
+}
diff --git a/core/api/src/test/java/org/onosproject/net/behaviour/TunnelEndPointTest.java b/core/api/src/test/java/org/onosproject/net/behaviour/TunnelEndPointTest.java
new file mode 100644
index 0000000..af76773
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/behaviour/TunnelEndPointTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.net.behaviour;
+
+import org.junit.Test;
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.NetTestTools;
+
+import com.google.common.testing.EqualsTester;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+public class TunnelEndPointTest {
+
+    private ConnectPoint cp1 = NetTestTools.connectPoint("cp1", 1);
+    private TunnelEndPoint<ConnectPoint> endPoint1 =
+            new TunnelEndPoint<>(cp1);
+    private TunnelEndPoint<ConnectPoint> sameAsEndPoint1 =
+            new TunnelEndPoint<>(cp1);
+
+    private ConnectPoint cp2 = NetTestTools.connectPoint("cp2", 2);
+    private TunnelEndPoint<ConnectPoint> endPoint2 =
+            new TunnelEndPoint<>(cp2);
+
+    private TunnelEndPoint<MacAddress> endPoint3 =
+            new TunnelEndPoint<>(MacAddress.BROADCAST);
+
+    @Test
+    public void testImmutability() {
+        assertThatClassIsImmutable(TunnelEndPoint.class);
+    }
+
+    @Test
+    public void testConstruction() {
+        assertThat(endPoint1.value(), is(cp1));
+        assertThat(endPoint1.strValue(), is(cp1.toString()));
+    }
+
+    @Test
+    public void testEquals() {
+        new EqualsTester()
+                .addEqualityGroup(endPoint1, sameAsEndPoint1)
+                .addEqualityGroup(endPoint2)
+                .addEqualityGroup(endPoint3)
+                .testEquals();
+    }
+}