Pushed Switch Mastership Events into the Topology event channel.
Needed for ONOS-1729
For now those events are not used.

Also, added new TopologyElement attribute type: TYPE_ALL_LAYERS
which applies to the Mastership Events.

NOTE: Currently, those events are intercepted within the
Floodlight Controller.java class. The interception point might be moved
once it becomes clear whether the event origin should be the mastership
election mechanism or the "role change request" accepted by the switch.
In addition, the interception point needs to be moved/ported as appropriate
once we move to the newer 1.3 OpenFlow driver implementation and eventloop.

Change-Id: Iff06ed5aee867c428a8378e31f9d51dbe3e6b978
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 e8e06b7..79dfc89 100644
--- a/src/test/java/net/onrc/onos/core/topology/TopologyManagerTest.java
+++ b/src/test/java/net/onrc/onos/core/topology/TopologyManagerTest.java
@@ -14,6 +14,7 @@
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
+import net.floodlightcontroller.core.IFloodlightProviderService.Role;
 import net.floodlightcontroller.util.MACAddress;
 import net.onrc.onos.core.datagrid.IDatagridService;
 import net.onrc.onos.core.datagrid.IEventChannel;
@@ -262,6 +263,59 @@
     }
 
     /**
+     * Test the Switch Mastership updated event.
+     */
+    @Test
+    public void testPutSwitchMastershipEvent() {
+        // Mock the eventChannel functions first
+        eventChannel.addEntry(anyObject(byte[].class),
+                anyObject(TopologyEvent.class));
+        EasyMock.expectLastCall().times(1, 1); // 1 event
+        replay(eventChannel);
+
+        setupTopologyManager();
+
+        // Generate a new Switch Mastership event
+        Dpid dpid = new Dpid(100L);
+        String onosInstanceId = "ONOS-Test-Instance-ID";
+        Role role = Role.MASTER;
+        MastershipEvent mastershipEvent =
+            new MastershipEvent(dpid, onosInstanceId, role);
+
+        // Call the topologyManager function for adding the event
+        theTopologyManager.putSwitchMastershipEvent(mastershipEvent);
+
+        // Verify the function calls
+        verify(eventChannel);
+    }
+
+    /**
+     * Test the Switch Mastership removed event.
+     */
+    @Test
+    public void testRemoveSwitchMastershipEvent() {
+        // Mock the eventChannel functions first
+        eventChannel.removeEntry(anyObject(byte[].class));
+        EasyMock.expectLastCall().times(1, 1); // 1 event
+        replay(eventChannel);
+
+        setupTopologyManager();
+
+        // Generate a new Switch Mastership event
+        Dpid dpid = new Dpid(100L);
+        String onosInstanceId = "ONOS-Test-Instance-ID";
+        Role role = Role.MASTER;
+        MastershipEvent mastershipEvent =
+            new MastershipEvent(dpid, onosInstanceId, role);
+
+        // Call the topologyManager function for removing the event
+        theTopologyManager.removeSwitchMastershipEvent(mastershipEvent);
+
+        // Verify the function calls
+        verify(eventChannel);
+    }
+
+    /**
      * Test the link discovered function.
      */
     @Test