ONOS-7066 ONOS-7067 PI abstractions refactoring and P4Info model parser

Includes changes previously reviewed in #15607, #15877, and #15955.

Change-Id: Ie2ff62e415f2099832ebfe05961a879b7b188fc3
diff --git a/core/api/src/test/java/org/onosproject/net/flow/criteria/PiCriteriaTest.java b/core/api/src/test/java/org/onosproject/net/flow/criteria/PiCriteriaTest.java
index f05dfaf..ab0446d 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/criteria/PiCriteriaTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/criteria/PiCriteriaTest.java
@@ -18,9 +18,9 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.runtime.PiExactFieldMatch;
 import org.onosproject.net.pi.runtime.PiFieldMatch;
-import org.onosproject.net.pi.runtime.PiHeaderFieldId;
 import org.onosproject.net.pi.runtime.PiLpmFieldMatch;
 import org.onosproject.net.pi.runtime.PiRangeFieldMatch;
 import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
@@ -38,195 +38,168 @@
  */
 public class PiCriteriaTest {
 
-    PiHeaderFieldId piEthHeaderFieldId = PiHeaderFieldId.of("ethernet_t", "etherType");
-    byte[] matchExactBytes1 = {0x08, 0x00};
-    byte[] matchExactBytes2 = {0x08, 0x06};
-    Criterion matchPiExactByte1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactBytes1).build();
-    Criterion sameAsMatchPiExactByte1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactBytes1).build();
-    Criterion matchPiExactByte2 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactBytes2).build();
+    private PiMatchFieldId ethMatchFieldId = PiMatchFieldId.of("ethernet_t.etherType");
+    private byte[] matchExactBytes1 = {0x08, 0x00};
+    private byte[] matchExactBytes2 = {0x08, 0x06};
+    private Criterion matchPiExactByte1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactBytes1).build();
+    private Criterion sameAsMatchPiExactByte1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactBytes1).build();
+    private Criterion matchPiExactByte2 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactBytes2).build();
 
-    short matchExactShort1 = 0x800;
-    short matchExactShort2 = 0x806;
-    Criterion matchPiExactShort1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactShort1).build();
-    Criterion sameAsMatchPiExactShort1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactShort1).build();
-    Criterion matchPiExactShort2 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactShort2).build();
+    private short matchExactShort1 = 0x800;
+    private short matchExactShort2 = 0x806;
+    private Criterion matchPiExactShort1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactShort1).build();
+    private Criterion sameAsMatchPiExactShort1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactShort1).build();
+    private Criterion matchPiExactShort2 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactShort2).build();
 
-    int matchExactInt1 = 0x800;
-    int matchExactInt2 = 0x806;
-    Criterion matchPiExactInt1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactInt1).build();
-    Criterion sameAsMatchPiExactInt1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactInt1).build();
-    Criterion matchPiExactInt2 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactInt2).build();
+    private int matchExactInt1 = 0x800;
+    private int matchExactInt2 = 0x806;
+    private Criterion matchPiExactInt1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactInt1).build();
+    private Criterion sameAsMatchPiExactInt1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactInt1).build();
+    private Criterion matchPiExactInt2 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactInt2).build();
 
-    long matchExactLong1 = 0x800;
-    long matchExactLong2 = 0x806;
-    Criterion matchPiExactLong1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactLong1).build();
-    Criterion sameAsMatchPiExactLong1 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactLong1).build();
-    Criterion matchPiExactLong2 = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactLong2).build();
+    private long matchExactLong1 = 0x800;
+    private long matchExactLong2 = 0x806;
+    private Criterion matchPiExactLong1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactLong1).build();
+    private Criterion sameAsMatchPiExactLong1 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactLong1).build();
+    private Criterion matchPiExactLong2 = PiCriterion.builder()
+            .matchExact(ethMatchFieldId, matchExactLong2).build();
 
-    PiHeaderFieldId piIpv4HeaderFieldId = PiHeaderFieldId.of("ipv4_t", "dstAddr");
-    int mask = 0x00ffffff;
-    byte[] matchLpmBytes1 = {0x0a, 0x01, 0x01, 0x01};
-    byte[] matchLpmBytes2 = {0x0a, 0x01, 0x01, 0x02};
-    Criterion matchPiLpmByte1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmBytes1, mask).build();
-    Criterion sameAsMatchPiLpmByte1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmBytes1, mask).build();
-    Criterion matchPiLpmByte2 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmBytes2, mask).build();
+    private PiMatchFieldId ipv4MatchFieldId = PiMatchFieldId.of("ipv4_t.dstAddr");
+    private int mask = 0x00ffffff;
+    private byte[] matchLpmBytes1 = {0x0a, 0x01, 0x01, 0x01};
+    private byte[] matchLpmBytes2 = {0x0a, 0x01, 0x01, 0x02};
+    private Criterion matchPiLpmByte1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmBytes1, mask).build();
+    private Criterion sameAsMatchPiLpmByte1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmBytes1, mask).build();
+    private Criterion matchPiLpmByte2 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmBytes2, mask).build();
 
-    short matchLpmShort1 = 0x0a0a;
-    short matchLpmShort2 = 0x0a0b;
-    Criterion matchPiLpmShort1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmShort1, mask).build();
-    Criterion sameAsMatchPiLpmShort1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId,
-            matchLpmShort1, mask)
-            .build();
-    Criterion matchPiLpmShort2 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmShort2, mask).build();
+    private short matchLpmShort1 = 0x0a0a;
+    private short matchLpmShort2 = 0x0a0b;
+    private Criterion matchPiLpmShort1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmShort1, mask).build();
+    private Criterion sameAsMatchPiLpmShort1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmShort1, mask).build();
+    private Criterion matchPiLpmShort2 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmShort2, mask).build();
 
-    int matchLpmInt1 = 0x0a010101;
-    int matchLpmInt2 = 0x0a010102;
-    Criterion matchPiLpmInt1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmInt1, mask).build();
-    Criterion sameAsMatchPiLpmInt1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmInt1, mask).build();
-    Criterion matchPiLpmInt2 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmInt2, mask).build();
+    private int matchLpmInt1 = 0x0a010101;
+    private int matchLpmInt2 = 0x0a010102;
+    private Criterion matchPiLpmInt1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmInt1, mask).build();
+    private Criterion sameAsMatchPiLpmInt1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmInt1, mask).build();
+    private Criterion matchPiLpmInt2 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmInt2, mask).build();
 
-    long matchLpmLong1 = 0x0a010101;
-    long matchLpmLong2 = 0x0a010102;
-    Criterion matchPiLpmLong1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmLong1, mask).build();
-    Criterion sameAsMatchPiLpmLong1 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmLong1, mask).build();
-    Criterion matchPiLpmLong2 = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmLong2, mask).build();
+    private long matchLpmLong1 = 0x0a010101;
+    private long matchLpmLong2 = 0x0a010102;
+    private Criterion matchPiLpmLong1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmLong1, mask).build();
+    private Criterion sameAsMatchPiLpmLong1 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmLong1, mask).build();
+    private Criterion matchPiLpmLong2 = PiCriterion.builder()
+            .matchLpm(ipv4MatchFieldId, matchLpmLong2, mask).build();
 
 
-    byte[] matchTernaryBytes1 = {0x0a, 0x01, 0x01, 0x01};
-    byte[] matchTernaryBytes2 = {0x0a, 0x01, 0x01, 0x02};
-    byte[] matchTernaryMaskBytes = {0x7f, 0x7f, 0x7f, 0x00};
-    Criterion matchPiTernaryByte1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryBytes1,
-            matchTernaryMaskBytes)
-            .build();
-    Criterion sameAsMatchPiTernaryByte1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryBytes1,
-            matchTernaryMaskBytes)
-            .build();
-    Criterion matchPiTernaryByte2 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryBytes2,
-            matchTernaryMaskBytes)
-            .build();
+    private byte[] matchTernaryBytes1 = {0x0a, 0x01, 0x01, 0x01};
+    private byte[] matchTernaryBytes2 = {0x0a, 0x01, 0x01, 0x02};
+    private byte[] matchTernaryMaskBytes = {0x7f, 0x7f, 0x7f, 0x00};
+    private Criterion matchPiTernaryByte1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryBytes1, matchTernaryMaskBytes).build();
+    private Criterion sameAsMatchPiTernaryByte1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryBytes1, matchTernaryMaskBytes).build();
+    private Criterion matchPiTernaryByte2 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryBytes2, matchTernaryMaskBytes).build();
 
-    short matchTernaryShort1 = 0x0a0a;
-    short matchTernaryShort2 = 0x0a0b;
-    short matchTernaryMaskShort = 0xff0;
-    Criterion matchPiTernaryShort1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryShort1,
-            matchTernaryMaskShort)
-            .build();
-    Criterion sameAsMatchPiTernaryShort1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryShort1,
-            matchTernaryMaskShort)
-            .build();
-    Criterion matchPiTernaryShort2 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryShort2,
-            matchTernaryMaskShort)
-            .build();
+    private short matchTernaryShort1 = 0x0a0a;
+    private short matchTernaryShort2 = 0x0a0b;
+    private short matchTernaryMaskShort = 0xff0;
+    private Criterion matchPiTernaryShort1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryShort1, matchTernaryMaskShort).build();
+    private Criterion sameAsMatchPiTernaryShort1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryShort1, matchTernaryMaskShort).build();
+    private Criterion matchPiTernaryShort2 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryShort2, matchTernaryMaskShort).build();
 
-    int matchTernaryInt1 = 0x0a010101;
-    int matchTernaryInt2 = 0x0a010102;
-    int matchTernaryMaskInt = 0xffff;
-    Criterion matchPiTernaryInt1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryInt1,
-            matchTernaryMaskInt)
-            .build();
-    Criterion sameAsMatchPiTernaryInt1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryInt1,
-            matchTernaryMaskInt)
-            .build();
-    Criterion matchPiTernaryInt2 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryInt2,
-            matchTernaryMaskInt)
-            .build();
+    private int matchTernaryInt1 = 0x0a010101;
+    private int matchTernaryInt2 = 0x0a010102;
+    private int matchTernaryMaskInt = 0xffff;
+    private Criterion matchPiTernaryInt1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryInt1, matchTernaryMaskInt).build();
+    private Criterion sameAsMatchPiTernaryInt1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryInt1, matchTernaryMaskInt).build();
+    private Criterion matchPiTernaryInt2 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryInt2, matchTernaryMaskInt).build();
 
-    long matchTernaryLong1 = 0x0a010101;
-    long matchTernaryLong2 = 0x0a010102;
-    long matchTernaryMaskLong = 0xffff;
-    Criterion matchPiTernaryLong1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryLong1,
-            matchTernaryMaskLong)
-            .build();
-    Criterion sameAsMatchPiTernaryLong1 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryLong1,
-            matchTernaryMaskLong)
-            .build();
-    Criterion matchPiTernaryLong2 = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId,
-            matchTernaryLong2,
-            matchTernaryMaskLong)
-            .build();
+    private long matchTernaryLong1 = 0x0a010101;
+    private long matchTernaryLong2 = 0x0a010102;
+    private long matchTernaryMaskLong = 0xffff;
+    private Criterion matchPiTernaryLong1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryLong1, matchTernaryMaskLong).build();
+    private Criterion sameAsMatchPiTernaryLong1 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryLong1, matchTernaryMaskLong).build();
+    private Criterion matchPiTernaryLong2 = PiCriterion.builder()
+            .matchTernary(ipv4MatchFieldId, matchTernaryLong2, matchTernaryMaskLong).build();
 
-    Criterion matchPiValid1 = PiCriterion.builder().matchValid(piIpv4HeaderFieldId, false).build();
-    Criterion sameAsMatchPiValid1 = PiCriterion.builder().matchValid(piIpv4HeaderFieldId, false).build();
-    Criterion matchPiValid2 = PiCriterion.builder().matchValid(piIpv4HeaderFieldId, true).build();
+    private Criterion matchPiValid1 = PiCriterion.builder().matchValid(ipv4MatchFieldId, false).build();
+    private Criterion sameAsMatchPiValid1 = PiCriterion.builder().matchValid(ipv4MatchFieldId, false).build();
+    private Criterion matchPiValid2 = PiCriterion.builder().matchValid(ipv4MatchFieldId, true).build();
 
-    byte[] matchRangeBytes1 = {0x10};
-    byte[] matchRangeBytes2 = {0x20};
-    byte[] matchRangeHighBytes = {0x30};
-    Criterion matchPiRangeByte1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeBytes1,
-            matchRangeHighBytes)
-            .build();
-    Criterion sameAsMatchPiRangeByte1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeBytes1,
-            matchRangeHighBytes)
-            .build();
-    Criterion matchPiRangeByte2 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeBytes2,
-            matchRangeHighBytes)
-            .build();
+    private byte[] matchRangeBytes1 = {0x10};
+    private byte[] matchRangeBytes2 = {0x20};
+    private byte[] matchRangeHighBytes = {0x30};
+    private Criterion matchPiRangeByte1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeBytes1, matchRangeHighBytes).build();
+    private Criterion sameAsMatchPiRangeByte1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeBytes1, matchRangeHighBytes).build();
+    private Criterion matchPiRangeByte2 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeBytes2, matchRangeHighBytes).build();
 
-    short matchRangeShort1 = 0x100;
-    short matchRangeShort2 = 0x200;
-    short matchRangeHighShort = 0x300;
-    Criterion matchPiRangeShort1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeShort1,
-            matchRangeHighShort)
-            .build();
-    Criterion sameAsMatchPiRangeShort1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeShort1,
-            matchRangeHighShort)
-            .build();
-    Criterion matchPiRangeShort2 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeShort2,
-            matchRangeHighShort)
-            .build();
+    private short matchRangeShort1 = 0x100;
+    private short matchRangeShort2 = 0x200;
+    private short matchRangeHighShort = 0x300;
+    private Criterion matchPiRangeShort1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeShort1, matchRangeHighShort).build();
+    private Criterion sameAsMatchPiRangeShort1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeShort1, matchRangeHighShort).build();
+    private Criterion matchPiRangeShort2 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeShort2, matchRangeHighShort).build();
 
-    int matchRangeInt1 = 0x100;
-    int matchRangeInt2 = 0x200;
-    int matchRangeHighInt = 0x300;
-    Criterion matchPiRangeInt1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeInt1,
-            matchRangeHighInt)
-            .build();
-    Criterion sameAsMatchPiRangeInt1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeInt1,
-            matchRangeHighInt)
-            .build();
-    Criterion matchPiRangeInt2 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeInt2,
-            matchRangeHighInt)
-            .build();
+    private int matchRangeInt1 = 0x100;
+    private int matchRangeInt2 = 0x200;
+    private int matchRangeHighInt = 0x300;
+    private Criterion matchPiRangeInt1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeInt1, matchRangeHighInt).build();
+    private Criterion sameAsMatchPiRangeInt1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeInt1, matchRangeHighInt).build();
+    private Criterion matchPiRangeInt2 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeInt2, matchRangeHighInt).build();
 
-    long matchRangeLong1 = 0x100;
-    long matchRangeLong2 = 0x200;
-    long matchRangeHighLong = 0x300;
-    Criterion matchPiRangeLong1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeLong1,
-            matchRangeHighLong)
-            .build();
-    Criterion sameAsMatchPiRangeLong1 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeLong1,
-            matchRangeHighLong)
-            .build();
-    Criterion matchPiRangeLong2 = PiCriterion.builder().matchRange(piIpv4HeaderFieldId,
-            matchRangeLong2,
-            matchRangeHighLong)
-            .build();
+    private long matchRangeLong1 = 0x100;
+    private long matchRangeLong2 = 0x200;
+    private long matchRangeHighLong = 0x300;
+    private Criterion matchPiRangeLong1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeLong1, matchRangeHighLong).build();
+    private Criterion sameAsMatchPiRangeLong1 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeLong1, matchRangeHighLong).build();
+    private Criterion matchPiRangeLong2 = PiCriterion.builder()
+            .matchRange(ipv4MatchFieldId, matchRangeLong2, matchRangeHighLong).build();
 
     /**
-     * Checks that a Criterion object has the proper type, and then converts
-     * it to the proper type.
+     * Checks that a Criterion object has the proper type, and then converts it to the proper type.
      *
      * @param criterion Criterion object to convert
      * @param type      Enumerated type value for the Criterion class
@@ -248,28 +221,28 @@
     @Test
     public void testExactMatchPiMethod() {
 
-        Criterion matchPiBytes = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactBytes1).build();
+        Criterion matchPiBytes = PiCriterion.builder().matchExact(ethMatchFieldId, matchExactBytes1).build();
         PiCriterion piCriterionBytes = checkAndConvert(matchPiBytes, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchBytes = new PiExactFieldMatch(piEthHeaderFieldId, copyFrom(matchExactBytes1));
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchBytes = new PiExactFieldMatch(ethMatchFieldId, copyFrom(matchExactBytes1));
         assertThat(piCriterionBytes.fieldMatches().iterator().next(), is(expectedMatchBytes));
 
-        Criterion matchPiShort = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactShort1).build();
+        Criterion matchPiShort = PiCriterion.builder().matchExact(ethMatchFieldId, matchExactShort1).build();
         PiCriterion piCriterionShort = checkAndConvert(matchPiShort, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchShort = new PiExactFieldMatch(piEthHeaderFieldId, copyFrom(matchExactShort1));
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchShort = new PiExactFieldMatch(ethMatchFieldId, copyFrom(matchExactShort1));
         assertThat(piCriterionShort.fieldMatches().iterator().next(), is(expectedMatchShort));
 
-        Criterion matchPiInt = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactInt1).build();
+        Criterion matchPiInt = PiCriterion.builder().matchExact(ethMatchFieldId, matchExactInt1).build();
         PiCriterion piCriterionInt = checkAndConvert(matchPiInt, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchInt = new PiExactFieldMatch(piEthHeaderFieldId, copyFrom(matchExactInt1));
+                                                     PiCriterion.class);
+        PiFieldMatch expectedMatchInt = new PiExactFieldMatch(ethMatchFieldId, copyFrom(matchExactInt1));
         assertThat(piCriterionInt.fieldMatches().iterator().next(), is(expectedMatchInt));
 
-        Criterion matchPiLong = PiCriterion.builder().matchExact(piEthHeaderFieldId, matchExactLong1).build();
+        Criterion matchPiLong = PiCriterion.builder().matchExact(ethMatchFieldId, matchExactLong1).build();
         PiCriterion piCriterionLong = checkAndConvert(matchPiLong, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchLong = new PiExactFieldMatch(piEthHeaderFieldId, copyFrom(matchExactLong1));
+                                                      PiCriterion.class);
+        PiFieldMatch expectedMatchLong = new PiExactFieldMatch(ethMatchFieldId, copyFrom(matchExactLong1));
         assertThat(piCriterionLong.fieldMatches().iterator().next(), is(expectedMatchLong));
     }
 
@@ -279,28 +252,28 @@
     @Test
     public void testLpmMatchPiMethod() {
 
-        Criterion matchPiBytes = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmBytes1, mask).build();
+        Criterion matchPiBytes = PiCriterion.builder().matchLpm(ipv4MatchFieldId, matchLpmBytes1, mask).build();
         PiCriterion piCriterionBytes = checkAndConvert(matchPiBytes, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchBytes = new PiLpmFieldMatch(piIpv4HeaderFieldId, copyFrom(matchLpmBytes1), mask);
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchBytes = new PiLpmFieldMatch(ipv4MatchFieldId, copyFrom(matchLpmBytes1), mask);
         assertThat(piCriterionBytes.fieldMatches().iterator().next(), is(expectedMatchBytes));
 
-        Criterion matchPiShort = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmShort1, mask).build();
+        Criterion matchPiShort = PiCriterion.builder().matchLpm(ipv4MatchFieldId, matchLpmShort1, mask).build();
         PiCriterion piCriterionShort = checkAndConvert(matchPiShort, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchShort = new PiLpmFieldMatch(piIpv4HeaderFieldId, copyFrom(matchLpmShort1), mask);
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchShort = new PiLpmFieldMatch(ipv4MatchFieldId, copyFrom(matchLpmShort1), mask);
         assertThat(piCriterionShort.fieldMatches().iterator().next(), is(expectedMatchShort));
 
-        Criterion matchPiInt = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmInt1, mask).build();
+        Criterion matchPiInt = PiCriterion.builder().matchLpm(ipv4MatchFieldId, matchLpmInt1, mask).build();
         PiCriterion piCriterionInt = checkAndConvert(matchPiInt, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchInt = new PiLpmFieldMatch(piIpv4HeaderFieldId, copyFrom(matchLpmInt1), mask);
+                                                     PiCriterion.class);
+        PiFieldMatch expectedMatchInt = new PiLpmFieldMatch(ipv4MatchFieldId, copyFrom(matchLpmInt1), mask);
         assertThat(piCriterionInt.fieldMatches().iterator().next(), is(expectedMatchInt));
 
-        Criterion matchPiLong = PiCriterion.builder().matchLpm(piIpv4HeaderFieldId, matchLpmLong1, mask).build();
+        Criterion matchPiLong = PiCriterion.builder().matchLpm(ipv4MatchFieldId, matchLpmLong1, mask).build();
         PiCriterion piCriterionLong = checkAndConvert(matchPiLong, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchLong = new PiLpmFieldMatch(piIpv4HeaderFieldId, copyFrom(matchLpmLong1), mask);
+                                                      PiCriterion.class);
+        PiFieldMatch expectedMatchLong = new PiLpmFieldMatch(ipv4MatchFieldId, copyFrom(matchLpmLong1), mask);
         assertThat(piCriterionLong.fieldMatches().iterator().next(), is(expectedMatchLong));
     }
 
@@ -310,40 +283,40 @@
     @Test
     public void testTernaryMatchPiMethod() {
 
-        Criterion matchPiBytes = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId, matchTernaryBytes1,
-                matchTernaryMaskBytes)
+        Criterion matchPiBytes = PiCriterion.builder().matchTernary(ipv4MatchFieldId, matchTernaryBytes1,
+                                                                    matchTernaryMaskBytes)
                 .build();
         PiCriterion piCriterionBytes = checkAndConvert(matchPiBytes, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchBytes = new PiTernaryFieldMatch(piIpv4HeaderFieldId, copyFrom(matchTernaryBytes1),
-                copyFrom(matchTernaryMaskBytes));
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchBytes = new PiTernaryFieldMatch(ipv4MatchFieldId, copyFrom(matchTernaryBytes1),
+                                                                  copyFrom(matchTernaryMaskBytes));
         assertThat(piCriterionBytes.fieldMatches().iterator().next(), is(expectedMatchBytes));
 
-        Criterion matchPiShort = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId, matchTernaryShort1,
-                matchTernaryMaskShort)
+        Criterion matchPiShort = PiCriterion.builder().matchTernary(ipv4MatchFieldId, matchTernaryShort1,
+                                                                    matchTernaryMaskShort)
                 .build();
         PiCriterion piCriterionShort = checkAndConvert(matchPiShort, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchShort = new PiTernaryFieldMatch(piIpv4HeaderFieldId, copyFrom(matchTernaryShort1),
-                copyFrom(matchTernaryMaskShort));
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchShort = new PiTernaryFieldMatch(ipv4MatchFieldId, copyFrom(matchTernaryShort1),
+                                                                  copyFrom(matchTernaryMaskShort));
         assertThat(piCriterionShort.fieldMatches().iterator().next(), is(expectedMatchShort));
 
-        Criterion matchPiInt = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId, matchTernaryInt1,
-                matchTernaryMaskInt)
+        Criterion matchPiInt = PiCriterion.builder().matchTernary(ipv4MatchFieldId, matchTernaryInt1,
+                                                                  matchTernaryMaskInt)
                 .build();
         PiCriterion piCriterionInt = checkAndConvert(matchPiInt, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchInt = new PiTernaryFieldMatch(piIpv4HeaderFieldId, copyFrom(matchTernaryInt1),
-                copyFrom(matchTernaryMaskInt));
+                                                     PiCriterion.class);
+        PiFieldMatch expectedMatchInt = new PiTernaryFieldMatch(ipv4MatchFieldId, copyFrom(matchTernaryInt1),
+                                                                copyFrom(matchTernaryMaskInt));
         assertThat(piCriterionInt.fieldMatches().iterator().next(), is(expectedMatchInt));
 
-        Criterion matchPiLong = PiCriterion.builder().matchTernary(piIpv4HeaderFieldId, matchTernaryLong1,
-                matchTernaryMaskLong)
+        Criterion matchPiLong = PiCriterion.builder().matchTernary(ipv4MatchFieldId, matchTernaryLong1,
+                                                                   matchTernaryMaskLong)
                 .build();
         PiCriterion piCriterionLong = checkAndConvert(matchPiLong, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchLong = new PiTernaryFieldMatch(piIpv4HeaderFieldId, copyFrom(matchTernaryLong1),
-                copyFrom(matchTernaryMaskLong));
+                                                      PiCriterion.class);
+        PiFieldMatch expectedMatchLong = new PiTernaryFieldMatch(ipv4MatchFieldId, copyFrom(matchTernaryLong1),
+                                                                 copyFrom(matchTernaryMaskLong));
         assertThat(piCriterionLong.fieldMatches().iterator().next(), is(expectedMatchLong));
     }
 
@@ -353,10 +326,10 @@
     @Test
     public void testValidMatchPiMethod() {
 
-        Criterion matchPiBytes = PiCriterion.builder().matchValid(piIpv4HeaderFieldId, true).build();
+        Criterion matchPiBytes = PiCriterion.builder().matchValid(ipv4MatchFieldId, true).build();
         PiCriterion piCriterionBytes = checkAndConvert(matchPiBytes, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatch = new PiValidFieldMatch(piIpv4HeaderFieldId, true);
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatch = new PiValidFieldMatch(ipv4MatchFieldId, true);
         assertThat(piCriterionBytes.fieldMatches().iterator().next(), is(expectedMatch));
     }
 
@@ -366,40 +339,40 @@
     @Test
     public void testRangeMatchPiMethod() {
 
-        Criterion matchPiBytes = PiCriterion.builder().matchRange(piIpv4HeaderFieldId, matchRangeBytes1,
-                matchRangeHighBytes)
+        Criterion matchPiBytes = PiCriterion.builder().matchRange(ipv4MatchFieldId, matchRangeBytes1,
+                                                                  matchRangeHighBytes)
                 .build();
         PiCriterion piCriterionBytes = checkAndConvert(matchPiBytes, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchBytes = new PiRangeFieldMatch(piIpv4HeaderFieldId, copyFrom(matchRangeBytes1),
-                copyFrom(matchRangeHighBytes));
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchBytes = new PiRangeFieldMatch(ipv4MatchFieldId, copyFrom(matchRangeBytes1),
+                                                                copyFrom(matchRangeHighBytes));
         assertThat(piCriterionBytes.fieldMatches().iterator().next(), is(expectedMatchBytes));
 
-        Criterion matchPiShort = PiCriterion.builder().matchRange(piIpv4HeaderFieldId, matchRangeShort1,
-                matchRangeHighShort)
+        Criterion matchPiShort = PiCriterion.builder().matchRange(ipv4MatchFieldId, matchRangeShort1,
+                                                                  matchRangeHighShort)
                 .build();
         PiCriterion piCriterionShort = checkAndConvert(matchPiShort, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchShort = new PiRangeFieldMatch(piIpv4HeaderFieldId, copyFrom(matchRangeShort1),
-                copyFrom(matchRangeHighShort));
+                                                       PiCriterion.class);
+        PiFieldMatch expectedMatchShort = new PiRangeFieldMatch(ipv4MatchFieldId, copyFrom(matchRangeShort1),
+                                                                copyFrom(matchRangeHighShort));
         assertThat(piCriterionShort.fieldMatches().iterator().next(), is(expectedMatchShort));
 
-        Criterion matchPiInt = PiCriterion.builder().matchRange(piIpv4HeaderFieldId, matchRangeInt1,
-                matchRangeHighInt)
+        Criterion matchPiInt = PiCriterion.builder().matchRange(ipv4MatchFieldId, matchRangeInt1,
+                                                                matchRangeHighInt)
                 .build();
         PiCriterion piCriterionInt = checkAndConvert(matchPiInt, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchInt = new PiRangeFieldMatch(piIpv4HeaderFieldId, copyFrom(matchRangeInt1),
-                copyFrom(matchRangeHighInt));
+                                                     PiCriterion.class);
+        PiFieldMatch expectedMatchInt = new PiRangeFieldMatch(ipv4MatchFieldId, copyFrom(matchRangeInt1),
+                                                              copyFrom(matchRangeHighInt));
         assertThat(piCriterionInt.fieldMatches().iterator().next(), is(expectedMatchInt));
 
-        Criterion matchPiLong = PiCriterion.builder().matchRange(piIpv4HeaderFieldId, matchRangeLong1,
-                matchRangeHighLong)
+        Criterion matchPiLong = PiCriterion.builder().matchRange(ipv4MatchFieldId, matchRangeLong1,
+                                                                 matchRangeHighLong)
                 .build();
         PiCriterion piCriterionLong = checkAndConvert(matchPiLong, Criterion.Type.PROTOCOL_INDEPENDENT,
-                PiCriterion.class);
-        PiFieldMatch expectedMatchLong = new PiRangeFieldMatch(piIpv4HeaderFieldId, copyFrom(matchRangeLong1),
-                copyFrom(matchRangeHighLong));
+                                                      PiCriterion.class);
+        PiFieldMatch expectedMatchLong = new PiRangeFieldMatch(ipv4MatchFieldId, copyFrom(matchRangeLong1),
+                                                               copyFrom(matchRangeHighLong));
         assertThat(piCriterionLong.fieldMatches().iterator().next(), is(expectedMatchLong));
     }
 
diff --git a/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java b/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
index ddf6500..68dc489 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
@@ -34,10 +34,10 @@
 import org.onosproject.net.flow.StatTriggerField;
 import org.onosproject.net.flow.StatTriggerFlag;
 import org.onosproject.net.meter.MeterId;
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiActionParamId;
 import org.onosproject.net.pi.runtime.PiAction;
-import org.onosproject.net.pi.runtime.PiActionId;
 import org.onosproject.net.pi.runtime.PiActionParam;
-import org.onosproject.net.pi.runtime.PiActionParamId;
 import org.onosproject.net.pi.runtime.PiTableAction;
 
 import java.util.EnumMap;
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberTest.java
index c9e53ee..020d575 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberTest.java
@@ -18,6 +18,8 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiActionParamId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -32,22 +34,22 @@
  */
 public class PiActionGroupMemberTest {
 
-    final PiActionGroupMemberId piActionGroupMemberId = PiActionGroupMemberId.of(10);
-    final PiAction piAction = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
+    private final PiActionGroupMemberId piActionGroupMemberId = PiActionGroupMemberId.of(10);
+    private final PiAction piAction = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
             .withParameter(new PiActionParam(PiActionParamId.of(DST_ADDR), copyFrom(0x0a010101)))
             .build();
 
-    final PiActionGroupMember piActionGroupMember1 = PiActionGroupMember.builder()
+    private final PiActionGroupMember piActionGroupMember1 = PiActionGroupMember.builder()
             .withId(piActionGroupMemberId)
             .withAction(piAction)
             .withWeight(10)
             .build();
-    final PiActionGroupMember sameAsPiActionGroupMember1 = PiActionGroupMember.builder()
+    private final PiActionGroupMember sameAsPiActionGroupMember1 = PiActionGroupMember.builder()
             .withId(piActionGroupMemberId)
             .withAction(piAction)
             .withWeight(10)
             .build();
-    final PiActionGroupMember piActionGroupMember2 = PiActionGroupMember.builder()
+    private final PiActionGroupMember piActionGroupMember2 = PiActionGroupMember.builder()
             .withId(piActionGroupMemberId)
             .withAction(piAction)
             .withWeight(20)
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupTest.java
index 0da15e4..6672d91 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupTest.java
@@ -20,6 +20,9 @@
 import com.google.common.testing.EqualsTester;
 import org.apache.commons.collections.CollectionUtils;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiActionGroupType;
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiActionParamId;
 
 import java.util.Collection;
 
@@ -37,36 +40,36 @@
  */
 public class PiActionGroupTest {
 
-    final PiActionGroupMemberId piActionGroupMemberId = PiActionGroupMemberId.of(10);
-    final PiAction piAction = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
+    private final PiActionGroupMemberId piActionGroupMemberId = PiActionGroupMemberId.of(10);
+    private final PiAction piAction = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
             .withParameter(new PiActionParam(PiActionParamId.of(DST_ADDR), copyFrom(0x0a010101)))
             .build();
 
-    final PiActionGroupMember piActionGroupMember = PiActionGroupMember.builder()
+    private final PiActionGroupMember piActionGroupMember = PiActionGroupMember.builder()
             .withId(piActionGroupMemberId)
             .withAction(piAction)
             .withWeight(10)
             .build();
-    PiActionGroupId piActionGroupId = PiActionGroupId.of(10);
-    PiActionGroup piActionGroup1 = PiActionGroup.builder()
+    private PiActionGroupId piActionGroupId = PiActionGroupId.of(10);
+    private PiActionGroup piActionGroup1 = PiActionGroup.builder()
             .addMember(piActionGroupMember)
             .withId(piActionGroupId)
-            .withType(PiActionGroup.Type.SELECT)
+            .withType(PiActionGroupType.SELECT)
             .withActionProfileId(ACTION_PROF_ID)
             .build();
 
-    PiActionGroup sameAsPiActionGroup1 = PiActionGroup.builder()
+    private PiActionGroup sameAsPiActionGroup1 = PiActionGroup.builder()
             .addMember(piActionGroupMember)
             .withId(piActionGroupId)
-            .withType(PiActionGroup.Type.SELECT)
+            .withType(PiActionGroupType.SELECT)
             .withActionProfileId(ACTION_PROF_ID)
             .build();
 
-    PiActionGroupId piActionGroupId2 = PiActionGroupId.of(20);
-    PiActionGroup piActionGroup2 = PiActionGroup.builder()
+    private PiActionGroupId piActionGroupId2 = PiActionGroupId.of(20);
+    private PiActionGroup piActionGroup2 = PiActionGroup.builder()
             .addMember(piActionGroupMember)
             .withId(piActionGroupId2)
-            .withType(PiActionGroup.Type.SELECT)
+            .withType(PiActionGroupType.SELECT)
             .withActionProfileId(ACTION_PROF_ID)
             .build();
 
@@ -102,7 +105,7 @@
         piActionGroupMembers.add(piActionGroupMember);
         assertThat(piActionGroup1, is(notNullValue()));
         assertThat(piActionGroup1.id(), is(piActionGroupId));
-        assertThat(piActionGroup1.type(), is(PiActionGroup.Type.SELECT));
+        assertThat(piActionGroup1.type(), is(PiActionGroupType.SELECT));
         assertThat("Incorrect members value",
                    CollectionUtils.isEqualCollection(piActionGroup1.members(), piActionGroupMembers));
     }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionIdTest.java
index 72e27af..262a50f 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionIdTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionIdTest.java
@@ -18,6 +18,7 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiActionId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -60,9 +61,8 @@
      */
     @Test
     public void testConstruction() {
-        final String id = DEC_TTL;
-        final PiActionId actionId = PiActionId.of(id);
+        final PiActionId actionId = PiActionId.of(DEC_TTL);
         assertThat(actionId, is(notNullValue()));
-        assertThat(actionId.name(), is(id));
+        assertThat(actionId.id(), is(DEC_TTL));
     }
 }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamIdTest.java
index b24adf0..c2793e7 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamIdTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamIdTest.java
@@ -18,6 +18,7 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiActionParamId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -60,8 +61,8 @@
     @Test
     public void testConstruction() {
         final String param = SRC_ADDR;
-        final PiActionParamId actionParamId = PiActionParamId.of(SRC_ADDR);
+        final PiActionParamId actionParamId = PiActionParamId.of(param);
         assertThat(actionParamId, is(notNullValue()));
-        assertThat(actionParamId.name(), is(param));
+        assertThat(actionParamId.id(), is(param));
     }
 }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamTest.java
index e8181b4..993c5e2 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionParamTest.java
@@ -19,6 +19,7 @@
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiActionParamId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -32,11 +33,11 @@
  * Unit tests for PiActionParam class.
  */
 public class PiActionParamTest {
-    ImmutableByteSequence value1 = copyFrom(0x0a010101);
-    ImmutableByteSequence value2 = copyFrom(0x0a010102);
-    final PiActionParam piActionParam1 = new PiActionParam(PiActionParamId.of(DST_ADDR), value1);
-    final PiActionParam sameAsPiActionParam1 = new PiActionParam(PiActionParamId.of(DST_ADDR), value1);
-    final PiActionParam piActionParam2 = new PiActionParam(PiActionParamId.of(DST_ADDR), value2);
+    private ImmutableByteSequence value1 = copyFrom(0x0a010101);
+    private ImmutableByteSequence value2 = copyFrom(0x0a010102);
+    private final PiActionParam piActionParam1 = new PiActionParam(PiActionParamId.of(DST_ADDR), value1);
+    private final PiActionParam sameAsPiActionParam1 = new PiActionParam(PiActionParamId.of(DST_ADDR), value1);
+    private final PiActionParam piActionParam2 = new PiActionParam(PiActionParamId.of(DST_ADDR), value2);
 
     /**
      * Checks that the PiActionParam class is immutable.
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionTest.java
index 86f8686..9a69ab3 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionTest.java
@@ -19,7 +19,8 @@
 import com.google.common.collect.Lists;
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
-
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiActionParamId;
 
 import java.util.Collection;
 
@@ -35,13 +36,13 @@
  * Unit tests for PiAction class.
  */
 public class PiActionTest {
-    final PiAction piAction1 = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
+    private final PiAction piAction1 = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
             .withParameter(new PiActionParam(PiActionParamId.of(DST_ADDR), copyFrom(0x0a010101)))
             .build();
-    final PiAction sameAsPiAction1 = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
+    private final PiAction sameAsPiAction1 = PiAction.builder().withId(PiActionId.of(MOD_NW_DST))
             .withParameter(new PiActionParam(PiActionParamId.of(DST_ADDR), copyFrom(0x0a010101)))
             .build();
-    final PiAction piAction2 = PiAction.builder().withId(PiActionId.of("set_egress_port_0")).build();
+    private final PiAction piAction2 = PiAction.builder().withId(PiActionId.of("set_egress_port_0")).build();
 
     /**
      * Checks that the PiAction class is immutable.
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiConstantsTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiConstantsTest.java
index 86f713d..158baab 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiConstantsTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiConstantsTest.java
@@ -15,30 +15,36 @@
  */
 package org.onosproject.net.pi.runtime;
 
+import org.onosproject.net.pi.model.PiActionProfileId;
+
 /**
- * Unit tests for PiActionId class.
+ * Constants for Pi* unit tests.
  */
 public final class PiConstantsTest {
-    private PiConstantsTest() {
-    }
-    public static final String MOD_NW_DST = "mod_nw_dst";
-    public static final String DEC_TTL = "dec_ttl";
-    public static final String MOD_VLAN_VID = "mod_vlan_vid";
+
+    static final String DOT = ".";
+    static final String MOD_NW_DST = "mod_nw_dst";
+    static final String DEC_TTL = "dec_ttl";
+    static final String MOD_VLAN_VID = "mod_vlan_vid";
     public static final String DROP = "drop";
 
-    public static final String IPV4_HEADER_NAME = "ipv4_t";
-    public static final String ETH_HEADER_NAME = "ethernet_t";
-    public static final String VLAN_HEADER_NAME = "vlan_tag_t";
+    static final String IPV4_HEADER_NAME = "ipv4_t";
+    static final String ETH_HEADER_NAME = "ethernet_t";
+    static final String VLAN_HEADER_NAME = "vlan_tag_t";
 
     public static final String ETH_TYPE = "etherType";
     public static final String DST_ADDR = "dstAddr";
-    public static final String SRC_ADDR = "srcAddr";
-    public static final String VID = "vid";
+    static final String SRC_ADDR = "srcAddr";
+    static final String VID = "vid";
     public static final String PORT = "port";
 
-    public static final String EGRESS_PORT = "egress_port";
-    public static final String INGRESS_PORT = "ingress_port";
+    static final String EGRESS_PORT = "egress_port";
+    static final String INGRESS_PORT = "ingress_port";
 
-    public static final PiActionProfileId ACTION_PROF_ID =
+    static final PiActionProfileId ACTION_PROF_ID =
             PiActionProfileId.of("Test action profile");
+
+    private PiConstantsTest() {
+        // Hides constructor.
+    }
 }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketMetadataIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiControlMetadataIdTest.java
similarity index 62%
rename from core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketMetadataIdTest.java
rename to core/api/src/test/java/org/onosproject/net/pi/runtime/PiControlMetadataIdTest.java
index a2ee50f..d65ef2e 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketMetadataIdTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiControlMetadataIdTest.java
@@ -18,6 +18,7 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiControlMetadataId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -27,21 +28,21 @@
 import static org.onosproject.net.pi.runtime.PiConstantsTest.INGRESS_PORT;
 
 /**
- * Unit tests for PiPacketMetadataId class.
+ * Unit tests for PiControlMetadataId class.
  */
-public class PiPacketMetadataIdTest {
+public class PiControlMetadataIdTest {
 
-    final PiPacketMetadataId piPacketMetadataId1 = PiPacketMetadataId.of(EGRESS_PORT);
-    final PiPacketMetadataId sameAsPiPacketMetadataId1 = PiPacketMetadataId.of(EGRESS_PORT);
-    final PiPacketMetadataId piPacketMetadataId2 = PiPacketMetadataId.of(INGRESS_PORT);
+    final PiControlMetadataId piControlMetadataId1 = PiControlMetadataId.of(EGRESS_PORT);
+    final PiControlMetadataId sameAsPiControlMetadataId1 = PiControlMetadataId.of(EGRESS_PORT);
+    final PiControlMetadataId piControlMetadataId2 = PiControlMetadataId.of(INGRESS_PORT);
 
     /**
-     * Checks that the PiPacketMetadataId class is immutable.
+     * Checks that the PiControlMetadataId class is immutable.
      */
     @Test
     public void testImmutability() {
 
-        assertThatClassIsImmutable(PiPacketMetadataId.class);
+        assertThatClassIsImmutable(PiControlMetadataId.class);
     }
 
     /**
@@ -51,18 +52,17 @@
     public void testEquals() {
 
         new EqualsTester()
-                .addEqualityGroup(piPacketMetadataId1, sameAsPiPacketMetadataId1)
-                .addEqualityGroup(piPacketMetadataId2)
+                .addEqualityGroup(piControlMetadataId1, sameAsPiControlMetadataId1)
+                .addEqualityGroup(piControlMetadataId2)
                 .testEquals();
     }
 
     /**
-     * Checks the methods of PiPacketMetadataId.
+     * Checks the methods of PiControlMetadataId.
      */
     @Test
     public void testMethods() {
-
-        assertThat(piPacketMetadataId1, is(notNullValue()));
-        assertThat(piPacketMetadataId1.name(), is(EGRESS_PORT));
+        assertThat(piControlMetadataId1, is(notNullValue()));
+        assertThat(piControlMetadataId1.id(), is(EGRESS_PORT));
     }
 }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiControlMetadataTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiControlMetadataTest.java
new file mode 100644
index 0000000..ab80fd6
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiControlMetadataTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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.pi.runtime;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onosproject.net.pi.model.PiControlMetadataId;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.EGRESS_PORT;
+
+/**
+ * Unit tests for PiControlMetadata class.
+ */
+public class PiControlMetadataTest {
+
+    final PiControlMetadataId piControlMetadataId = PiControlMetadataId.of(EGRESS_PORT);
+
+    final PiControlMetadata piControlMetadata1 = PiControlMetadata.builder()
+            .withId(piControlMetadataId)
+            .withValue(copyFrom(0x10))
+            .build();
+    final PiControlMetadata sameAsPiControlMetadata1 = PiControlMetadata.builder()
+            .withId(piControlMetadataId)
+            .withValue(copyFrom(0x10))
+            .build();
+    final PiControlMetadata piControlMetadata2 = PiControlMetadata.builder()
+            .withId(piControlMetadataId)
+            .withValue(copyFrom(0x20))
+            .build();
+
+    /**
+     * Checks that the PiControlMetadata class is immutable.
+     */
+    @Test
+    public void testImmutability() {
+
+        assertThatClassIsImmutable(PiControlMetadata.class);
+    }
+
+    /**
+     * Checks the operation of equals(), hashCode() and toString() methods.
+     */
+    @Test
+    public void testEquals() {
+
+        new EqualsTester()
+                .addEqualityGroup(piControlMetadata1, sameAsPiControlMetadata1)
+                .addEqualityGroup(piControlMetadata2)
+                .testEquals();
+    }
+
+    /**
+     * Checks the methods of PiControlMetadata.
+     */
+    @Test
+    public void testMethods() {
+
+        assertThat(piControlMetadata1, is(notNullValue()));
+        assertThat(piControlMetadata1.id(), is(PiControlMetadataId.of(EGRESS_PORT)));
+        assertThat(piControlMetadata1.value(), is(copyFrom(0x10)));
+    }
+}
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiExactFieldMatchTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiExactFieldMatchTest.java
index af331c6..38b6765 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiExactFieldMatchTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiExactFieldMatchTest.java
@@ -19,6 +19,7 @@
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -26,6 +27,7 @@
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_HEADER_NAME;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_TYPE;
 
@@ -33,12 +35,13 @@
  * Unit tests for PiExactFieldMatch class.
  */
 public class PiExactFieldMatchTest {
-    final ImmutableByteSequence value1 = copyFrom(0x0800);
-    final ImmutableByteSequence value2 = copyFrom(0x0806);
-    final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(ETH_HEADER_NAME, ETH_TYPE);
-    PiExactFieldMatch piExactFieldMatch1 = new PiExactFieldMatch(piHeaderField, value1);
-    PiExactFieldMatch sameAsPiExactFieldMatch1 = new PiExactFieldMatch(piHeaderField, value1);
-    PiExactFieldMatch piExactFieldMatch2 = new PiExactFieldMatch(piHeaderField, value2);
+
+    private final ImmutableByteSequence value1 = copyFrom(0x0800);
+    private final ImmutableByteSequence value2 = copyFrom(0x0806);
+    private final PiMatchFieldId piMatchField = PiMatchFieldId.of(ETH_HEADER_NAME + DOT + ETH_TYPE);
+    private PiExactFieldMatch piExactFieldMatch1 = new PiExactFieldMatch(piMatchField, value1);
+    private PiExactFieldMatch sameAsPiExactFieldMatch1 = new PiExactFieldMatch(piMatchField, value1);
+    private PiExactFieldMatch piExactFieldMatch2 = new PiExactFieldMatch(piMatchField, value2);
 
     /**
      * Checks that the PiExactFieldMatch class is immutable.
@@ -65,8 +68,8 @@
     @Test
     public void testConstruction() {
         final ImmutableByteSequence value = copyFrom(0x0806);
-        final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(ETH_HEADER_NAME, ETH_TYPE);
-        PiExactFieldMatch piExactFieldMatch = new PiExactFieldMatch(piHeaderField, value);
+        final PiMatchFieldId piMatchField = PiMatchFieldId.of(ETH_HEADER_NAME + DOT + ETH_TYPE);
+        PiExactFieldMatch piExactFieldMatch = new PiExactFieldMatch(piMatchField, value);
         assertThat(piExactFieldMatch, is(notNullValue()));
         assertThat(piExactFieldMatch.value(), is(value));
         assertThat(piExactFieldMatch.type(), is(PiMatchType.EXACT));
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiFieldMatchTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiFieldMatchTest.java
index 89f9442..2e63d45 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiFieldMatchTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiFieldMatchTest.java
@@ -17,11 +17,13 @@
 package org.onosproject.net.pi.runtime;
 
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static org.junit.Assert.assertEquals;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutableBaseClass;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_HEADER_NAME;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_TYPE;
 
@@ -41,10 +43,10 @@
 
     @Test
     public void basics() {
-        final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(ETH_HEADER_NAME, ETH_TYPE);
-        PiFieldMatch piFieldMatch = new PiExactFieldMatch(piHeaderField, copyFrom(0x0806));
+        final PiMatchFieldId piMatchField = PiMatchFieldId.of(ETH_HEADER_NAME + DOT + ETH_TYPE);
+        PiFieldMatch piFieldMatch = new PiExactFieldMatch(piMatchField, copyFrom(0x0806));
 
-        assertEquals(piFieldMatch.fieldId(), piHeaderField);
+        assertEquals(piFieldMatch.fieldId(), piMatchField);
         assertEquals(piFieldMatch.type(), PiMatchType.EXACT);
     }
 }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiHeaderFieldIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiHeaderFieldIdTest.java
deleted file mode 100644
index 8521d5c..0000000
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiHeaderFieldIdTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.pi.runtime;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_HEADER_NAME;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_TYPE;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.IPV4_HEADER_NAME;
-
-/**
- * Unit tests for PiHeaderFieldId class.
- */
-public class PiHeaderFieldIdTest {
-    final String headerName = ETH_HEADER_NAME;
-    final String dstAddr = DST_ADDR;
-    final String etherType = ETH_TYPE;
-
-    final PiHeaderFieldId piHeaderFieldId1 = PiHeaderFieldId.of(headerName, dstAddr);
-    final PiHeaderFieldId sameAsPiHeaderFieldId1 = PiHeaderFieldId.of(headerName, dstAddr);
-    final PiHeaderFieldId piHeaderFieldId2 = PiHeaderFieldId.of(headerName, etherType);
-
-    int index = 10;
-    final PiHeaderFieldId piHeaderFieldId1WithIndex = PiHeaderFieldId.of(headerName, dstAddr, index);
-    final PiHeaderFieldId sameAsPiHeaderFieldId1WithIndex = PiHeaderFieldId.of(headerName, dstAddr, index);
-    final PiHeaderFieldId piHeaderFieldId2WithIndex = PiHeaderFieldId.of(headerName, etherType, index);
-
-    /**
-     * Checks that the PiHeaderFieldId class is immutable.
-     */
-    @Test
-    public void testImmutability() {
-        assertThatClassIsImmutable(PiHeaderFieldId.class);
-    }
-
-    /**
-     * Checks the operation of equals(), hashCode() and toString() methods.
-     */
-    @Test
-    public void testEquals() {
-        new EqualsTester()
-                .addEqualityGroup(piHeaderFieldId1, sameAsPiHeaderFieldId1)
-                .addEqualityGroup(piHeaderFieldId2)
-                .testEquals();
-    }
-
-    /**
-     * Checks the operation of equals(), hashCode() and toString() methods.
-     */
-    @Test
-    public void testEqualsWithIndex() {
-        new EqualsTester()
-                .addEqualityGroup(piHeaderFieldId1WithIndex, sameAsPiHeaderFieldId1WithIndex)
-                .addEqualityGroup(piHeaderFieldId2WithIndex)
-                .testEquals();
-    }
-
-    /**
-     * Checks the construction of a PiHeaderFieldId object.
-     */
-    @Test
-    public void testConstruction() {
-        final String name = IPV4_HEADER_NAME;
-        final String field = DST_ADDR;
-
-        final PiHeaderFieldId piHeaderFieldId = PiHeaderFieldId.of(name, field);
-        assertThat(piHeaderFieldId, is(notNullValue()));
-        assertThat(piHeaderFieldId.headerName(), is(name));
-        assertThat(piHeaderFieldId.fieldName(), is(field));
-    }
-
-    /**
-     * Checks the construction of a PiHeaderFieldId object with index.
-     */
-    @Test
-    public void testConstructionWithIndex() {
-        final String name = IPV4_HEADER_NAME;
-        final String field = DST_ADDR;
-        final int index = 1;
-        final PiHeaderFieldId piHeaderFieldId = PiHeaderFieldId.of(name, field, index);
-        assertThat(piHeaderFieldId, is(notNullValue()));
-        assertThat(piHeaderFieldId.headerName(), is(name));
-        assertThat(piHeaderFieldId.fieldName(), is(field));
-        assertThat(piHeaderFieldId.index(), is(index));
-    }
-}
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiLpmFieldMatchTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiLpmFieldMatchTest.java
index a25c434..8257fcc 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiLpmFieldMatchTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiLpmFieldMatchTest.java
@@ -19,6 +19,7 @@
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -26,6 +27,7 @@
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.IPV4_HEADER_NAME;
 
@@ -33,13 +35,13 @@
  * Unit tests for PiLpmFieldMatch class.
  */
 public class PiLpmFieldMatchTest {
-    final ImmutableByteSequence value1 = copyFrom(0x0a010101);
-    final ImmutableByteSequence value2 = copyFrom(0x0a010102);
-    int prefixLength = 24;
-    final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(IPV4_HEADER_NAME, DST_ADDR);
-    PiLpmFieldMatch piLpmFieldMatch1 = new PiLpmFieldMatch(piHeaderField, value1, prefixLength);
-    PiLpmFieldMatch sameAsPiLpmFieldMatch1 = new PiLpmFieldMatch(piHeaderField, value1, prefixLength);
-    PiLpmFieldMatch piLpmFieldMatch2 = new PiLpmFieldMatch(piHeaderField, value2, prefixLength);
+    private final ImmutableByteSequence value1 = copyFrom(0x0a010101);
+    private final ImmutableByteSequence value2 = copyFrom(0x0a010102);
+    private int prefixLength = 24;
+    private final PiMatchFieldId piMatchField = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR);
+    private PiLpmFieldMatch piLpmFieldMatch1 = new PiLpmFieldMatch(piMatchField, value1, prefixLength);
+    private PiLpmFieldMatch sameAsPiLpmFieldMatch1 = new PiLpmFieldMatch(piMatchField, value1, prefixLength);
+    private PiLpmFieldMatch piLpmFieldMatch2 = new PiLpmFieldMatch(piMatchField, value2, prefixLength);
 
     /**
      * Checks that the PiLpmFieldMatch class is immutable.
@@ -67,8 +69,8 @@
     public void testConstruction() {
         final ImmutableByteSequence value = copyFrom(0x0a01010a);
         int prefix = 24;
-        final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(IPV4_HEADER_NAME, DST_ADDR);
-        PiLpmFieldMatch piLpmFieldMatch = new PiLpmFieldMatch(piHeaderField, value, prefix);
+        final PiMatchFieldId piMatchField = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR);
+        PiLpmFieldMatch piLpmFieldMatch = new PiLpmFieldMatch(piMatchField, value, prefix);
         assertThat(piLpmFieldMatch, is(notNullValue()));
         assertThat(piLpmFieldMatch.value(), is(value));
         assertThat(piLpmFieldMatch.prefixLength(), is(prefix));
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchFieldIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchFieldIdTest.java
new file mode 100644
index 0000000..2724da0
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchFieldIdTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.pi.runtime;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onosproject.net.pi.model.PiMatchFieldId;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_HEADER_NAME;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.ETH_TYPE;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.IPV4_HEADER_NAME;
+
+/**
+ * Unit tests for PiMatchFieldId class.
+ */
+public class PiMatchFieldIdTest {
+    private final String headerName = ETH_HEADER_NAME;
+    private final String dstAddr = DST_ADDR;
+    private final String etherType = ETH_TYPE;
+
+    private final PiMatchFieldId piMatchFieldId1 = PiMatchFieldId.of(headerName + DOT + dstAddr);
+    private final PiMatchFieldId sameAsPiMatchFieldId1 = PiMatchFieldId.of(headerName + DOT + dstAddr);
+    private final PiMatchFieldId piMatchFieldId2 = PiMatchFieldId.of(headerName + DOT + etherType);
+
+    private int index = 10;
+    private final PiMatchFieldId piMatchFieldId1WithIndex = PiMatchFieldId
+            .of(headerName + DOT + dstAddr + "[" + index + "]");
+    private final PiMatchFieldId sameAsPiMatchFieldId1WithIndex = PiMatchFieldId
+            .of(headerName + DOT + dstAddr + "[" + index + "]");
+    private final PiMatchFieldId piMatchFieldId2WithIndex = PiMatchFieldId
+            .of(headerName + DOT + etherType + "[" + index + "]");
+
+    /**
+     * Checks that the PiMatchFieldId class is immutable.
+     */
+    @Test
+    public void testImmutability() {
+        assertThatClassIsImmutable(PiMatchFieldId.class);
+    }
+
+    /**
+     * Checks the operation of equals(), hashCode() and toString() methods.
+     */
+    @Test
+    public void testEquals() {
+        new EqualsTester()
+                .addEqualityGroup(piMatchFieldId1, sameAsPiMatchFieldId1)
+                .addEqualityGroup(piMatchFieldId2)
+                .testEquals();
+    }
+
+    /**
+     * Checks the operation of equals(), hashCode() and toString() methods.
+     */
+    @Test
+    public void testEqualsWithIndex() {
+        new EqualsTester()
+                .addEqualityGroup(piMatchFieldId1WithIndex, sameAsPiMatchFieldId1WithIndex)
+                .addEqualityGroup(piMatchFieldId2WithIndex)
+                .testEquals();
+    }
+
+    /**
+     * Checks the construction of a PiMatchFieldId object.
+     */
+    @Test
+    public void testConstruction() {
+        final String name = IPV4_HEADER_NAME  + DOT + DST_ADDR;
+        final PiMatchFieldId piMatchFieldId = PiMatchFieldId.of(name);
+        assertThat(piMatchFieldId, is(notNullValue()));
+        assertThat(piMatchFieldId.id(), is(name));
+    }
+
+    /**
+     * Checks the construction of a PiMatchFieldId object with index.
+     */
+    @Test
+    public void testConstructionWithIndex() {
+        final String name = IPV4_HEADER_NAME + DOT + DST_ADDR + "[1]";
+        final PiMatchFieldId piMatchFieldId = PiMatchFieldId.of(name);
+        assertThat(piMatchFieldId, is(notNullValue()));
+        assertThat(piMatchFieldId.id(), is(name));
+    }
+}
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchKeyTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchKeyTest.java
index ea866fa..a6d62af 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchKeyTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiMatchKeyTest.java
@@ -21,6 +21,7 @@
 import org.apache.commons.collections.CollectionUtils;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 
 import java.util.Collection;
 
@@ -29,6 +30,7 @@
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.IPV4_HEADER_NAME;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.SRC_ADDR;
@@ -38,21 +40,21 @@
  */
 public class PiMatchKeyTest {
 
-    final ImmutableByteSequence value1 = copyFrom(0x0a010101);
-    final ImmutableByteSequence value2 = copyFrom(0x0a010102);
-    int prefixLength = 24;
-    final PiHeaderFieldId piHeaderField1 = PiHeaderFieldId.of(IPV4_HEADER_NAME, SRC_ADDR);
-    final PiHeaderFieldId piHeaderField2 = PiHeaderFieldId.of(IPV4_HEADER_NAME, DST_ADDR);
-    PiLpmFieldMatch piLpmFieldMatch1 = new PiLpmFieldMatch(piHeaderField1, value1, prefixLength);
-    PiLpmFieldMatch piLpmFieldMatch2 = new PiLpmFieldMatch(piHeaderField2, value2, prefixLength);
+    private final ImmutableByteSequence value1 = copyFrom(0x0a010101);
+    private final ImmutableByteSequence value2 = copyFrom(0x0a010102);
+    private int prefixLength = 24;
+    private final PiMatchFieldId piMatchField1 = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + SRC_ADDR);
+    private final PiMatchFieldId piMatchField2 = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR);
+    private PiLpmFieldMatch piLpmFieldMatch1 = new PiLpmFieldMatch(piMatchField1, value1, prefixLength);
+    private PiLpmFieldMatch piLpmFieldMatch2 = new PiLpmFieldMatch(piMatchField2, value2, prefixLength);
 
-    final PiMatchKey piMatchKey1 = PiMatchKey.builder()
+    private final PiMatchKey piMatchKey1 = PiMatchKey.builder()
             .addFieldMatch(piLpmFieldMatch1)
             .build();
-    final PiMatchKey sameAsPiMatchKey1 = PiMatchKey.builder()
+    private final PiMatchKey sameAsPiMatchKey1 = PiMatchKey.builder()
             .addFieldMatch(piLpmFieldMatch1)
             .build();
-    final PiMatchKey piMatchKey2 = PiMatchKey.builder()
+    private final PiMatchKey piMatchKey2 = PiMatchKey.builder()
             .addFieldMatch(piLpmFieldMatch2)
             .build();
 
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketMetadataTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketMetadataTest.java
deleted file mode 100644
index 8ba4d4e..0000000
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketMetadataTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.pi.runtime;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onlab.util.ImmutableByteSequence.copyFrom;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.EGRESS_PORT;
-
-/**
- * Unit tests for PiPacketMetadata class.
- */
-public class PiPacketMetadataTest {
-
-    final PiPacketMetadataId piPacketMetadataId = PiPacketMetadataId.of(EGRESS_PORT);
-
-    final PiPacketMetadata piPacketMetadata1 = PiPacketMetadata.builder()
-            .withId(piPacketMetadataId)
-            .withValue(copyFrom(0x10))
-            .build();
-    final PiPacketMetadata sameAsPiPacketMetadata1 = PiPacketMetadata.builder()
-            .withId(piPacketMetadataId)
-            .withValue(copyFrom(0x10))
-            .build();
-    final PiPacketMetadata piPacketMetadata2 = PiPacketMetadata.builder()
-            .withId(piPacketMetadataId)
-            .withValue(copyFrom(0x20))
-            .build();
-
-    /**
-     * Checks that the PiPacketMetadata class is immutable.
-     */
-    @Test
-    public void testImmutability() {
-
-        assertThatClassIsImmutable(PiPacketMetadata.class);
-    }
-
-    /**
-     * Checks the operation of equals(), hashCode() and toString() methods.
-     */
-    @Test
-    public void testEquals() {
-
-        new EqualsTester()
-                .addEqualityGroup(piPacketMetadata1, sameAsPiPacketMetadata1)
-                .addEqualityGroup(piPacketMetadata2)
-                .testEquals();
-    }
-
-    /**
-     * Checks the methods of PiPacketMetadata.
-     */
-    @Test
-    public void testMethods() {
-
-        assertThat(piPacketMetadata1, is(notNullValue()));
-        assertThat(piPacketMetadata1.id(), is(PiPacketMetadataId.of(EGRESS_PORT)));
-        assertThat(piPacketMetadata1.value(), is(copyFrom(0x10)));
-    }
-}
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketOperationTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketOperationTest.java
index 619099f..d675b51 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketOperationTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiPacketOperationTest.java
@@ -21,43 +21,50 @@
 import org.apache.commons.collections.CollectionUtils;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.pi.model.PiControlMetadataId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.model.PiPacketOperationType.PACKET_OUT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.EGRESS_PORT;
-import static org.onosproject.net.pi.runtime.PiPacketOperation.Type.PACKET_OUT;
 
 /**
  * Unit tests for PiPacketOperation class.
  */
 public class PiPacketOperationTest {
 
-    final PiPacketOperation piPacketOperation1 = PiPacketOperation.builder()
+    private final DeviceId deviceId = DeviceId.deviceId("dummy");
+
+    private final PiPacketOperation piPacketOperation1 = PiPacketOperation.builder()
+            .forDevice(deviceId)
             .withData(ImmutableByteSequence.ofOnes(512))
             .withType(PACKET_OUT)
-            .withMetadata(PiPacketMetadata.builder()
-                                  .withId(PiPacketMetadataId.of(EGRESS_PORT))
+            .withMetadata(PiControlMetadata.builder()
+                                  .withId(PiControlMetadataId.of(EGRESS_PORT))
                                   .withValue(copyFrom((short) 255))
                                   .build())
             .build();
 
-    final PiPacketOperation sameAsPiPacketOperation1 = PiPacketOperation.builder()
+    private final PiPacketOperation sameAsPiPacketOperation1 = PiPacketOperation.builder()
+            .forDevice(deviceId)
             .withData(ImmutableByteSequence.ofOnes(512))
             .withType(PACKET_OUT)
-            .withMetadata(PiPacketMetadata.builder()
-                                  .withId(PiPacketMetadataId.of(EGRESS_PORT))
+            .withMetadata(PiControlMetadata.builder()
+                                  .withId(PiControlMetadataId.of(EGRESS_PORT))
                                   .withValue(copyFrom((short) 255))
                                   .build())
             .build();
 
-    final PiPacketOperation piPacketOperation2 = PiPacketOperation.builder()
+    private final PiPacketOperation piPacketOperation2 = PiPacketOperation.builder()
+            .forDevice(deviceId)
             .withData(ImmutableByteSequence.ofOnes(512))
             .withType(PACKET_OUT)
-            .withMetadata(PiPacketMetadata.builder()
-                                  .withId(PiPacketMetadataId.of(EGRESS_PORT))
+            .withMetadata(PiControlMetadata.builder()
+                                  .withId(PiControlMetadataId.of(EGRESS_PORT))
                                   .withValue(copyFrom((short) 200))
                                   .build())
             .build();
@@ -90,21 +97,23 @@
     public void testMethods() {
 
         final PiPacketOperation piPacketOperation = PiPacketOperation.builder()
+                .forDevice(deviceId)
                 .withData(ImmutableByteSequence.ofOnes(512))
                 .withType(PACKET_OUT)
-                .withMetadata(PiPacketMetadata.builder()
-                                      .withId(PiPacketMetadataId.of(EGRESS_PORT))
+                .withMetadata(PiControlMetadata.builder()
+                                      .withId(PiControlMetadataId.of(EGRESS_PORT))
                                       .withValue(copyFrom((short) 10))
                                       .build())
                 .build();
 
         assertThat(piPacketOperation, is(notNullValue()));
+        assertThat(piPacketOperation.deviceId(), is(deviceId));
         assertThat(piPacketOperation.type(), is(PACKET_OUT));
         assertThat(piPacketOperation.data(), is(ImmutableByteSequence.ofOnes(512)));
         assertThat("Incorrect metadatas value",
                    CollectionUtils.isEqualCollection(piPacketOperation.metadatas(),
-                                                     ImmutableList.of(PiPacketMetadata.builder()
-                                                                              .withId(PiPacketMetadataId
+                                                     ImmutableList.of(PiControlMetadata.builder()
+                                                                              .withId(PiControlMetadataId
                                                                                               .of(EGRESS_PORT))
                                                                               .withValue(copyFrom((short) 10))
                                                                               .build())));
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiRangeFieldMatchTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiRangeFieldMatchTest.java
index 27c551c..7fb28b9 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiRangeFieldMatchTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiRangeFieldMatchTest.java
@@ -19,6 +19,7 @@
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -26,6 +27,7 @@
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.VID;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.VLAN_HEADER_NAME;
 
@@ -33,15 +35,15 @@
  * Unit tests for PiRangeFieldMatch class.
  */
 public class PiRangeFieldMatchTest {
-    final ImmutableByteSequence high1 = copyFrom(0x10);
-    final ImmutableByteSequence low1 = copyFrom(0x00);
-    final ImmutableByteSequence high2 = copyFrom(0x30);
-    final ImmutableByteSequence low2 = copyFrom(0x40);
+    private final ImmutableByteSequence high1 = copyFrom(0x10);
+    private final ImmutableByteSequence low1 = copyFrom(0x00);
+    private final ImmutableByteSequence high2 = copyFrom(0x30);
+    private final ImmutableByteSequence low2 = copyFrom(0x40);
 
-    final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(VLAN_HEADER_NAME, VID);
-    PiRangeFieldMatch piRangeFieldMatch1 = new PiRangeFieldMatch(piHeaderField, low1, high1);
-    PiRangeFieldMatch sameAsPiRangeFieldMatch1 = new PiRangeFieldMatch(piHeaderField, low1, high1);
-    PiRangeFieldMatch piRangeFieldMatch2 = new PiRangeFieldMatch(piHeaderField, low2, high2);
+    private final PiMatchFieldId piMatchField = PiMatchFieldId.of(VLAN_HEADER_NAME + DOT + VID);
+    private PiRangeFieldMatch piRangeFieldMatch1 = new PiRangeFieldMatch(piMatchField, low1, high1);
+    private PiRangeFieldMatch sameAsPiRangeFieldMatch1 = new PiRangeFieldMatch(piMatchField, low1, high1);
+    private PiRangeFieldMatch piRangeFieldMatch2 = new PiRangeFieldMatch(piMatchField, low2, high2);
 
     /**
      * Checks that the PiRangeFieldMatch class is immutable.
@@ -69,8 +71,8 @@
     public void testConstruction() {
         final ImmutableByteSequence high = copyFrom(0x50);
         final ImmutableByteSequence low = copyFrom(0x00);
-        final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(VLAN_HEADER_NAME, VID);
-        PiRangeFieldMatch piRangeFieldMatch = new PiRangeFieldMatch(piHeaderField, low, high);
+        final PiMatchFieldId piMatchField = PiMatchFieldId.of(VLAN_HEADER_NAME + DOT + VID);
+        PiRangeFieldMatch piRangeFieldMatch = new PiRangeFieldMatch(piMatchField, low, high);
         assertThat(piRangeFieldMatch, is(notNullValue()));
         assertThat(piRangeFieldMatch.lowValue(), is(low));
         assertThat(piRangeFieldMatch.highValue(), is(high));
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableEntryTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableEntryTest.java
index 6caa63c..0b451e8 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableEntryTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableEntryTest.java
@@ -21,13 +21,19 @@
 import org.apache.commons.collections.CollectionUtils;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiMatchFieldId;
+import org.onosproject.net.pi.model.PiTableId;
 
 import java.util.Map;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.*;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DROP;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.IPV4_HEADER_NAME;
 
 /**
  * Unit tests for PiTableEntry class.
@@ -94,11 +100,11 @@
         long cookie = 0xfff0323;
         int priority = 100;
         double timeout = 1000;
-        PiHeaderFieldId piHeaderFieldId = PiHeaderFieldId.of(IPV4_HEADER_NAME, DST_ADDR);
-        PiFieldMatch piFieldMatch = new PiExactFieldMatch(piHeaderFieldId, ImmutableByteSequence.copyFrom(0x0a010101));
+        PiMatchFieldId piMatchFieldId = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR);
+        PiFieldMatch piFieldMatch = new PiExactFieldMatch(piMatchFieldId, ImmutableByteSequence.copyFrom(0x0a010101));
         PiAction piAction = PiAction.builder().withId(PiActionId.of(DROP)).build();
-        final Map<PiHeaderFieldId, PiFieldMatch> fieldMatches = Maps.newHashMap();
-        fieldMatches.put(piHeaderFieldId, piFieldMatch);
+        final Map<PiMatchFieldId, PiFieldMatch> fieldMatches = Maps.newHashMap();
+        fieldMatches.put(piMatchFieldId, piFieldMatch);
         final PiTableEntry piTableEntry = PiTableEntry.builder()
                 .forTable(piTableId)
                 .withMatchKey(PiMatchKey.builder()
@@ -112,6 +118,8 @@
 
         assertThat(piTableEntry.table(), is(piTableId));
         assertThat(piTableEntry.cookie(), is(cookie));
+        assertThat("Priority must be set", piTableEntry.priority().isPresent());
+        assertThat("Timeout must be set", piTableEntry.timeout().isPresent());
         assertThat(piTableEntry.priority().get(), is(priority));
         assertThat(piTableEntry.timeout().get(), is(timeout));
         assertThat("Incorrect match param value",
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableIdTest.java
index d343cd7..eb1de71 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableIdTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTableIdTest.java
@@ -18,6 +18,7 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiTableId;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -28,16 +29,12 @@
  * Unit tests for PiTableId class.
  */
 public class PiTableIdTest {
-    final String table10 = "table10";
-    final String table20 = "table20";
-    final PiTableId piTableId1 = PiTableId.of(table10);
-    final PiTableId sameAsPiTableId1 = PiTableId.of(table10);
-    final PiTableId piTableId2 = PiTableId.of(table20);
+    private final String table10 = "table10";
+    private final String table20 = "table20";
+    private final PiTableId piTableId1 = PiTableId.of(table10);
+    private final PiTableId sameAsPiTableId1 = PiTableId.of(table10);
+    private final PiTableId piTableId2 = PiTableId.of(table20);
 
-    final String tableScope = "local";
-    final PiTableId piTableIdWithScope1 = PiTableId.of(tableScope, table10);
-    final PiTableId sameAsPiTableIdWithScope1 = PiTableId.of(tableScope, table10);
-    final PiTableId piTableIdWithScope2 = PiTableId.of(tableScope, table20);
     /**
      * Checks that the PiTableId class is immutable.
      */
@@ -58,37 +55,11 @@
     }
 
     /**
-     * Checks the operation of equals(), hashCode() and toString() methods.
-     */
-    @Test
-    public void testEqualsWithScope() {
-        new EqualsTester()
-                .addEqualityGroup(piTableIdWithScope1, sameAsPiTableIdWithScope1)
-                .addEqualityGroup(piTableIdWithScope2)
-                .testEquals();
-    }
-
-    /**
      * Checks the construction of a PiTableId object.
      */
     @Test
     public void testConstruction() {
-        final String name = "table1";
-        final PiTableId piTableId = PiTableId.of(name);
-        assertThat(piTableId, is(notNullValue()));
-        assertThat(piTableId.name(), is(name));
-    }
-
-    /**
-     * Checks the construction of a PiTableId object.
-     */
-    @Test
-    public void testConstructionWithScope() {
-        final String name = "table1";
-        final String scope = "local";
-        final PiTableId piTableId = PiTableId.of(scope, name);
-        assertThat(piTableId, is(notNullValue()));
-        assertThat(piTableId.name(), is(name));
-        assertThat(piTableId.scope().get(), is(scope));
+        assertThat(piTableId1, is(notNullValue()));
+        assertThat(piTableId1.id(), is(table10));
     }
 }
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTernaryFieldMatchTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTernaryFieldMatchTest.java
index 2078496..f36ba6b 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTernaryFieldMatchTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiTernaryFieldMatchTest.java
@@ -19,6 +19,7 @@
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
 import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -26,6 +27,7 @@
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 import static org.onlab.util.ImmutableByteSequence.copyFrom;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.IPV4_HEADER_NAME;
 
@@ -33,15 +35,15 @@
  * Unit tests for PiTernaryFieldMatch class.
  */
 public class PiTernaryFieldMatchTest {
-    final ImmutableByteSequence value1 = copyFrom(0x0a010101);
-    final ImmutableByteSequence mask1 = copyFrom(0x00ffffff);
-    final ImmutableByteSequence value2 = copyFrom(0x0a010102);
-    final ImmutableByteSequence mask2 = copyFrom(0x0000ffff);
+    private final ImmutableByteSequence value1 = copyFrom(0x0a010101);
+    private final ImmutableByteSequence mask1 = copyFrom(0x00ffffff);
+    private final ImmutableByteSequence value2 = copyFrom(0x0a010102);
+    private final ImmutableByteSequence mask2 = copyFrom(0x0000ffff);
 
-    final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(IPV4_HEADER_NAME, DST_ADDR);
-    PiTernaryFieldMatch piTernaryFieldMatch1 = new PiTernaryFieldMatch(piHeaderField, value1, mask1);
-    PiTernaryFieldMatch sameAsPiTernaryFieldMatch1 = new PiTernaryFieldMatch(piHeaderField, value1, mask1);
-    PiTernaryFieldMatch piTernaryFieldMatch2 = new PiTernaryFieldMatch(piHeaderField, value2, mask2);
+    private final PiMatchFieldId piMatchField = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR);
+    private PiTernaryFieldMatch piTernaryFieldMatch1 = new PiTernaryFieldMatch(piMatchField, value1, mask1);
+    private PiTernaryFieldMatch sameAsPiTernaryFieldMatch1 = new PiTernaryFieldMatch(piMatchField, value1, mask1);
+    private PiTernaryFieldMatch piTernaryFieldMatch2 = new PiTernaryFieldMatch(piMatchField, value2, mask2);
 
     /**
      * Checks that the PiTernaryFieldMatch class is immutable.
@@ -69,8 +71,8 @@
     public void testConstruction() {
         final ImmutableByteSequence value = copyFrom(0x0a01010a);
         final ImmutableByteSequence mask = copyFrom(0x00ffffff);
-        final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(IPV4_HEADER_NAME, DST_ADDR);
-        PiTernaryFieldMatch piTernaryFieldMatch = new PiTernaryFieldMatch(piHeaderField, value, mask);
+        final PiMatchFieldId piMatchField = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR);
+        PiTernaryFieldMatch piTernaryFieldMatch = new PiTernaryFieldMatch(piMatchField, value, mask);
         assertThat(piTernaryFieldMatch, is(notNullValue()));
         assertThat(piTernaryFieldMatch.value(), is(value));
         assertThat(piTernaryFieldMatch.mask(), is(mask));
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiValidFieldMatchTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiValidFieldMatchTest.java
index 6a32ed1..a62588a 100644
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiValidFieldMatchTest.java
+++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiValidFieldMatchTest.java
@@ -18,12 +18,14 @@
 
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
+import org.onosproject.net.pi.model.PiMatchFieldId;
 import org.onosproject.net.pi.model.PiMatchType;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.notNullValue;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.VID;
 import static org.onosproject.net.pi.runtime.PiConstantsTest.VLAN_HEADER_NAME;
 
@@ -31,13 +33,12 @@
  * Unit tests for PiValidFieldMatch class.
  */
 public class PiValidFieldMatchTest {
-
-    final boolean isValid1 = true;
-    final boolean isValid2 = false;
-    final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(VLAN_HEADER_NAME, VID);
-    PiValidFieldMatch piValidFieldMatch1 = new PiValidFieldMatch(piHeaderField, isValid1);
-    PiValidFieldMatch sameAsPiValidFieldMatch1 = new PiValidFieldMatch(piHeaderField, isValid1);
-    PiValidFieldMatch piValidFieldMatch2 = new PiValidFieldMatch(piHeaderField, isValid2);
+    private final boolean isValid1 = true;
+    private final boolean isValid2 = false;
+    private final PiMatchFieldId piMatchField = PiMatchFieldId.of(VLAN_HEADER_NAME + DOT + VID);
+    private PiValidFieldMatch piValidFieldMatch1 = new PiValidFieldMatch(piMatchField, isValid1);
+    private PiValidFieldMatch sameAsPiValidFieldMatch1 = new PiValidFieldMatch(piMatchField, isValid1);
+    private PiValidFieldMatch piValidFieldMatch2 = new PiValidFieldMatch(piMatchField, isValid2);
 
     /**
      * Checks that the PiValidFieldMatch class is immutable.
@@ -63,11 +64,8 @@
      */
     @Test
     public void testConstruction() {
-        final boolean isValid = true;
-        final PiHeaderFieldId piHeaderField = PiHeaderFieldId.of(VLAN_HEADER_NAME, VID);
-        PiValidFieldMatch piTernaryFieldMatch = new PiValidFieldMatch(piHeaderField, isValid);
-        assertThat(piTernaryFieldMatch, is(notNullValue()));
-        assertThat(piTernaryFieldMatch.isValid(), is(isValid));
-        assertThat(piTernaryFieldMatch.type(), is(PiMatchType.VALID));
+        assertThat(piValidFieldMatch1, is(notNullValue()));
+        assertThat(piValidFieldMatch1.isValid(), is(isValid1));
+        assertThat(piValidFieldMatch1.type(), is(PiMatchType.VALID));
     }
 }