Work toward ONOS-1451: Separate Event Key space per instance

Misc changes and cleanup (Step 2):
 * Added OnosInstanceId field to class TopologyEvent. For now it is
   just assigned, but is not used.

 * Minor refactoring of class TopologyEvent so it will be easier to make it
   immutable after its its internals and usage are inalized.

 * Modified the signature of method PathIntentMap.getIntentsByLink()
   to use LinkTuple for the lookup instead of LinkEvent.

 * Replaced (only inside onos/core/topology) the usage of Apache's
   Validate with Google's Preconditions for null-checking and assignment.

   With Apache's Validate we have to use two statements:
    Validate.notNull(foo);
    this.foo = foo;

   With Google's Preconditions we can do it with a single statement:
    this.foo = checkNotNull(foo);

   NOTE: Apache's commons-lang version 3.x adds Google's semantics.
   In the future, we need to decide (across all ONOS code) whether
   to use Google's Preconditions or Apache's Validate 3.x

 * Removed one of the LinkEvent convenience constructors, because it is used
   only in 1-2 places in the unit tests, and nowhere in the main code.

 * Few other (minor) cleanup changes

Change-Id: I05dae593ae1244a0af23515e7c73911f21275479
diff --git a/src/test/java/net/onrc/onos/core/topology/TopologyManagerTest.java b/src/test/java/net/onrc/onos/core/topology/TopologyManagerTest.java
index 9bdffd5..f7fe753 100644
--- a/src/test/java/net/onrc/onos/core/topology/TopologyManagerTest.java
+++ b/src/test/java/net/onrc/onos/core/topology/TopologyManagerTest.java
@@ -50,6 +50,7 @@
     private IControllerRegistryService registryService;
     private CopyOnWriteArrayList<ITopologyListener> topologyListeners;
     private Collection<TopologyEvent> allTopologyEvents;
+    private OnosInstanceId onosInstanceId = new OnosInstanceId("ONOS-Test-Instance-ID");
 
     @SuppressWarnings("unchecked")
     @Before
@@ -107,6 +108,8 @@
                 anyObject(LinkEvent.class)))
                 .andReturn(true).anyTimes();
 
+        expect(registryService.getOnosInstanceId()).andReturn(onosInstanceId).anyTimes();
+
         replay(datagridService);
         replay(registryService);
         replay(dataStoreService);
@@ -275,11 +278,9 @@
 
         // Generate a new Switch Mastership event
         Dpid dpid = new Dpid(100L);
-        OnosInstanceId onosInstanceId =
-            new OnosInstanceId("ONOS-Test-Instance-ID");
         Role role = Role.MASTER;
         MastershipEvent mastershipEvent =
-            new MastershipEvent(dpid, onosInstanceId, role);
+            new MastershipEvent(dpid, this.onosInstanceId, role);
 
         // Call the topologyManager function for adding the event
         theTopologyManager.putSwitchMastershipEvent(mastershipEvent);
@@ -302,11 +303,9 @@
 
         // Generate a new Switch Mastership event
         Dpid dpid = new Dpid(100L);
-        OnosInstanceId onosInstanceId =
-            new OnosInstanceId("ONOS-Test-Instance-ID");
         Role role = Role.MASTER;
         MastershipEvent mastershipEvent =
-            new MastershipEvent(dpid, onosInstanceId, role);
+            new MastershipEvent(dpid, this.onosInstanceId, role);
 
         // Call the topologyManager function for removing the event
         theTopologyManager.removeSwitchMastershipEvent(mastershipEvent);
@@ -351,7 +350,8 @@
         theTopologyManager.putSwitchDiscoveryEvent(switchEvent2, portEvents2);
 
         // Create the link
-        LinkEvent linkEvent = new LinkEvent(sw1DPId, port1Id, sw2DPId, port2Id);
+        LinkEvent linkEvent = new LinkEvent(new SwitchPort(sw1DPId, port1Id),
+                                            new SwitchPort(sw2DPId, port2Id));
         theTopologyManager.putLinkDiscoveryEvent(linkEvent);
 
         // Verify the function calls
@@ -393,7 +393,9 @@
         theTopologyManager.putSwitchDiscoveryEvent(switchEvent2, portEvents2);
 
         // Remove the link
-        LinkEvent linkEventRemove = new LinkEvent(sw1DPId, port1Id, sw2DPId, port2Id);
+        LinkEvent linkEventRemove =
+            new LinkEvent(new SwitchPort(sw1DPId, port1Id),
+                          new SwitchPort(sw2DPId, port2Id));
         theTopologyManager.removeLinkDiscoveryEvent(linkEventRemove);
 
         // Verify the function calls