P4Runtime unit tests for api, ctl, model modules

Change-Id: Iac1b1ef6e274c355ce3a26cffbd8adcb39694f69
diff --git a/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4ControlMetadataModelTest.java b/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4ControlMetadataModelTest.java
new file mode 100644
index 0000000..998875a
--- /dev/null
+++ b/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4ControlMetadataModelTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.p4runtime.model;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onosproject.net.pi.model.PiControlMetadataId;
+
+import static org.junit.Assert.*;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * Test for P4ControlMetadataModel class.
+ */
+public class P4ControlMetadataModelTest {
+
+    private final PiControlMetadataId piControlMetadataId = PiControlMetadataId.of("EGRESS_PORT");
+    private final PiControlMetadataId sameAsPiControlMetadataId = PiControlMetadataId.of("EGRESS_PORT");
+    private final PiControlMetadataId piControlMetadataId2 = PiControlMetadataId.of("INGRESS_PORT");
+
+    private static final int BIT_WIDTH_32 = 32;
+    private static final int BIT_WIDTH_64 = 64;
+
+    private final P4ControlMetadataModel metadataModel = new P4ControlMetadataModel(piControlMetadataId, BIT_WIDTH_32);
+
+    private final P4ControlMetadataModel sameAsMetadataModel = new P4ControlMetadataModel(sameAsPiControlMetadataId,
+                                                                                          BIT_WIDTH_32);
+
+    private final P4ControlMetadataModel metadataModel2 = new P4ControlMetadataModel(piControlMetadataId2,
+                                                                                     BIT_WIDTH_32);
+
+    private final P4ControlMetadataModel metadataModel3 = new P4ControlMetadataModel(piControlMetadataId, BIT_WIDTH_64);
+
+
+
+    /**
+     * Checks that the P4CounterModel class is immutable.
+     */
+    @Test
+    public void testImmutability() {
+        assertThatClassIsImmutable(P4ControlMetadataModel.class);
+    }
+
+    /**
+     * Checks the operation of equals(), hashCode() and toString() methods.
+     */
+    @Test
+    public void testEquals() {
+        new EqualsTester()
+                .addEqualityGroup(metadataModel, sameAsMetadataModel)
+                .addEqualityGroup(metadataModel2)
+                .addEqualityGroup(metadataModel3)
+                .testEquals();
+    }
+}
\ No newline at end of file