Adding port, port number, port description implementations and related tests.
diff --git a/net/api/src/test/java/org/onlab/onos/event/AbstractEventTest.java b/net/api/src/test/java/org/onlab/onos/event/AbstractEventTest.java
index 5ec3669..b79b836 100644
--- a/net/api/src/test/java/org/onlab/onos/event/AbstractEventTest.java
+++ b/net/api/src/test/java/org/onlab/onos/event/AbstractEventTest.java
@@ -11,12 +11,46 @@
  */
 public class AbstractEventTest {
 
+    /**
+     * Validates the base attributes of an event.
+     *
+     * @param event   event to validate
+     * @param type    event type
+     * @param subject event subject
+     * @param time    event time
+     * @param <T>     type of event
+     * @param <S>     type of subject
+     */
+    protected static <T extends Enum, S>
+    void validateEvent(Event<T, S> event, T type, S subject, long time) {
+        assertEquals("incorrect type", type, event.type());
+        assertEquals("incorrect subject", subject, event.subject());
+        assertEquals("incorrect time", time, event.time());
+    }
+
+    /**
+     * Validates the base attributes of an event.
+     *
+     * @param event   event to validate
+     * @param type    event type
+     * @param subject event subject
+     * @param minTime minimum event time inclusive
+     * @param maxTime maximum event time inclusive
+     * @param <T>     type of event
+     * @param <S>     type of subject
+     */
+    protected static <T extends Enum, S>
+    void validateEvent(Event<T, S> event, T type, S subject,
+                       long minTime, long maxTime) {
+        assertEquals("incorrect type", type, event.type());
+        assertEquals("incorrect subject", subject, event.subject());
+        assertTrue("incorrect time", minTime <= event.time() && event.time() <= maxTime);
+    }
+
     @Test
     public void withTime() {
         TestEvent event = new TestEvent(FOO, "foo", 123L);
-        assertEquals("incorrect type", FOO, event.type());
-        assertEquals("incorrect subject", "foo", event.subject());
-        assertEquals("incorrect time", 123L, event.time());
+        validateEvent(event, FOO, "foo", 123L);
     }
 
     @Test
@@ -24,8 +58,7 @@
         long before = System.currentTimeMillis();
         TestEvent event = new TestEvent(FOO, "foo");
         long after = System.currentTimeMillis();
-        assertEquals("incorrect type", FOO, event.type());
-        assertEquals("incorrect subject", "foo", event.subject());
-        assertTrue("incorrect time", before <= event.time() && event.time() <= after);
+        validateEvent(event, FOO, "foo", before, after);
     }
+
 }
diff --git a/net/api/src/test/java/org/onlab/onos/net/DefaultDeviceTest.java b/net/api/src/test/java/org/onlab/onos/net/DefaultDeviceTest.java
index 1d174ca..c37a15c 100644
--- a/net/api/src/test/java/org/onlab/onos/net/DefaultDeviceTest.java
+++ b/net/api/src/test/java/org/onlab/onos/net/DefaultDeviceTest.java
@@ -4,10 +4,9 @@
 import org.junit.Test;
 import org.onlab.onos.net.provider.ProviderId;
 
-import java.net.URI;
-
 import static org.junit.Assert.assertEquals;
 import static org.onlab.onos.net.Device.Type.SWITCH;
+import static org.onlab.onos.net.DeviceId.deviceId;
 
 /**
  * Test of the default device model entity.
@@ -15,8 +14,8 @@
 public class DefaultDeviceTest {
 
     private static final ProviderId PID = new ProviderId("foo");
-    private static final DeviceId DID1 = new DeviceId(URI.create("of:foo"));
-    private static final DeviceId DID2 = new DeviceId(URI.create("of:bar"));
+    private static final DeviceId DID1 = deviceId("of:foo");
+    private static final DeviceId DID2 = deviceId("of:bar");
     private static final String MFR = "whitebox";
     private static final String HW = "1.1.x";
     private static final String SW = "3.9.1";
diff --git a/net/api/src/test/java/org/onlab/onos/net/DeviceIdTest.java b/net/api/src/test/java/org/onlab/onos/net/DeviceIdTest.java
index f373678..eaee54c 100644
--- a/net/api/src/test/java/org/onlab/onos/net/DeviceIdTest.java
+++ b/net/api/src/test/java/org/onlab/onos/net/DeviceIdTest.java
@@ -3,17 +3,19 @@
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
 
+import static org.onlab.onos.net.DeviceId.deviceId;
+
 /**
- * Test of the provider identifier.
+ * Test of the device identifier.
  */
 public class DeviceIdTest extends ElementIdTest {
 
     @Test
     public void basics() {
         new EqualsTester()
-                .addEqualityGroup(new DeviceId(uri("of:foo")),
-                                  new DeviceId(uri("of:foo")))
-                .addEqualityGroup(new DeviceId(uri("of:bar")))
+                .addEqualityGroup(deviceId("of:foo"),
+                                  deviceId("of:foo"))
+                .addEqualityGroup(deviceId("of:bar"))
                 .testEquals();
     }
 
diff --git a/net/api/src/test/java/org/onlab/onos/net/ElementIdTest.java b/net/api/src/test/java/org/onlab/onos/net/ElementIdTest.java
index 4de68dd..cf209b3 100644
--- a/net/api/src/test/java/org/onlab/onos/net/ElementIdTest.java
+++ b/net/api/src/test/java/org/onlab/onos/net/ElementIdTest.java
@@ -8,10 +8,16 @@
 import static org.junit.Assert.assertEquals;
 
 /**
- * Test of the provider identifier.
+ * Test of the network element identifier.
  */
 public class ElementIdTest {
 
+    private static class FooId extends ElementId {
+        public FooId(URI uri) {
+            super(uri);
+        }
+    }
+
     public static URI uri(String str) {
         return URI.create(str);
     }
@@ -19,12 +25,12 @@
     @Test
     public void basics() {
         new EqualsTester()
-                .addEqualityGroup(new ElementId(uri("of:foo")),
-                                  new ElementId(uri("of:foo")))
-                .addEqualityGroup(new ElementId(uri("of:bar")))
+                .addEqualityGroup(new FooId(uri("of:foo")),
+                                  new FooId(uri("of:foo")))
+                .addEqualityGroup(new FooId(uri("of:bar")))
                 .testEquals();
         assertEquals("wrong uri", uri("ofcfg:foo"),
-                     new ElementId(uri("ofcfg:foo")).uri());
+                     new FooId(uri("ofcfg:foo")).uri());
     }
 
 }
diff --git a/net/api/src/test/java/org/onlab/onos/net/PortNumberTest.java b/net/api/src/test/java/org/onlab/onos/net/PortNumberTest.java
new file mode 100644
index 0000000..fced985
--- /dev/null
+++ b/net/api/src/test/java/org/onlab/onos/net/PortNumberTest.java
@@ -0,0 +1,37 @@
+package org.onlab.onos.net;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.onlab.onos.net.PortNumber.portNumber;
+
+/**
+ * Test of the port number.
+ */
+public class PortNumberTest extends ElementIdTest {
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+                .addEqualityGroup(portNumber(123),
+                                  portNumber("123"))
+                .addEqualityGroup(portNumber(321))
+                .testEquals();
+    }
+
+    @Test
+    public void number() {
+        assertEquals("incorrect long value", 12345, portNumber(12345).toLong());
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void negative() {
+        portNumber(-1);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void tooBig() {
+        portNumber((2L * Integer.MAX_VALUE) + 2);
+    }
+}
diff --git a/net/api/src/test/java/org/onlab/onos/net/device/DeviceEventTest.java b/net/api/src/test/java/org/onlab/onos/net/device/DeviceEventTest.java
new file mode 100644
index 0000000..df2b419
--- /dev/null
+++ b/net/api/src/test/java/org/onlab/onos/net/device/DeviceEventTest.java
@@ -0,0 +1,39 @@
+package org.onlab.onos.net.device;
+
+import org.junit.Test;
+import org.onlab.onos.event.AbstractEventTest;
+import org.onlab.onos.net.DefaultDevice;
+import org.onlab.onos.net.Device;
+import org.onlab.onos.net.provider.ProviderId;
+
+import static org.onlab.onos.net.DeviceId.deviceId;
+
+/**
+ * Tests of the device event.
+ */
+public class DeviceEventTest extends AbstractEventTest {
+
+    private Device createDevice() {
+        return new DefaultDevice(new ProviderId("foo"), deviceId("of:foo"),
+                                 Device.Type.SWITCH, "box", "hw", "sw", "sn");
+    }
+
+    @Test
+    public void withTime() {
+        Device device = createDevice();
+        DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED,
+                                            device, 123L);
+        validateEvent(event, DeviceEvent.Type.DEVICE_ADDED, device, 123L);
+    }
+
+    @Test
+    public void withoutTime() {
+        Device device = createDevice();
+        long before = System.currentTimeMillis();
+        DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED,
+                                            device);
+        long after = System.currentTimeMillis();
+        validateEvent(event, DeviceEvent.Type.DEVICE_ADDED, device, before, after);
+    }
+
+}