Wired up the match-action REST APIs to the MatchActionModule

Change-Id: Ifcbd27c83cac716435afb5f6869431d02500ce5b
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
index 8255035..72fd717 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
@@ -14,9 +14,11 @@
 import net.floodlightcontroller.core.module.FloodlightModuleException;
 import net.floodlightcontroller.core.module.IFloodlightModule;
 import net.floodlightcontroller.core.module.IFloodlightService;
+import net.floodlightcontroller.restserver.IRestApiService;
 import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
 import net.onrc.onos.core.datagrid.IDatagridService;
 import net.onrc.onos.core.flowprogrammer.IFlowPusherService;
+import net.onrc.onos.core.matchaction.web.MatchActionWebRoutable;
 import net.onrc.onos.core.registry.IControllerRegistryService;
 import net.onrc.onos.core.util.IdGenerator;
 
@@ -57,6 +59,7 @@
         dependencies.add(IFlowPusherService.class);
         dependencies.add(IFloodlightProviderService.class);
         dependencies.add(IControllerRegistryService.class);
+        dependencies.add(IRestApiService.class);
         return dependencies;
     }
 
@@ -71,6 +74,9 @@
         final IFlowPusherService pusher = context.getServiceImpl(IFlowPusherService.class);
         final IFloodlightProviderService provider = context.getServiceImpl(IFloodlightProviderService.class);
         final IControllerRegistryService registry = context.getServiceImpl(IControllerRegistryService.class);
+        final IRestApiService restApi = context.getServiceImpl(IRestApiService.class);
+
+        restApi.addRestletRoutable(new MatchActionWebRoutable());
 
         matchActionComponent = new MatchActionComponent(datagrid, pusher, provider, registry);
         log.info("match action component created");
diff --git a/src/main/java/net/onrc/onos/core/matchaction/web/MatchActionResource.java b/src/main/java/net/onrc/onos/core/matchaction/web/MatchActionResource.java
index 037ee88..20e68d3 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/web/MatchActionResource.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/web/MatchActionResource.java
@@ -5,8 +5,8 @@
 
 import net.floodlightcontroller.restserver.CustomSerializerHelper;
 import net.onrc.onos.core.matchaction.MatchAction;
+import net.onrc.onos.core.matchaction.MatchActionFloodlightService;
 import net.onrc.onos.core.matchaction.MatchActionId;
-import net.onrc.onos.core.matchaction.MatchActionService;
 
 import org.codehaus.jackson.JsonGenerator;
 import org.codehaus.jackson.JsonProcessingException;
@@ -49,9 +49,9 @@
      */
     @Get("json")
     public Representation retrieve() {
-        MatchActionService matchActionService =
-                (MatchActionService) getContext().getAttributes()
-                    .get(MatchActionService.class.getCanonicalName());
+        MatchActionFloodlightService matchActionService =
+                (MatchActionFloodlightService) getContext().getAttributes()
+                    .get(MatchActionFloodlightService.class.getCanonicalName());
 
         Set<MatchAction> matchActions = matchActionService.getMatchActions();
 
diff --git a/src/main/java/net/onrc/onos/core/matchaction/web/MatchActionWebRoutable.java b/src/main/java/net/onrc/onos/core/matchaction/web/MatchActionWebRoutable.java
index 638b0ad..544f88e 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/web/MatchActionWebRoutable.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/web/MatchActionWebRoutable.java
@@ -13,7 +13,7 @@
 
     @Override
     public Restlet getRestlet(Context context) {
-        Router router = new Router();
+        Router router = new Router(context);
         router.attach("", MatchActionResource.class);
         return router;
     }
diff --git a/src/test/java/net/onrc/onos/core/matchaction/web/MatchActionResourceTest.java b/src/test/java/net/onrc/onos/core/matchaction/web/MatchActionResourceTest.java
index 6bea4ff..6d35f78 100644
--- a/src/test/java/net/onrc/onos/core/matchaction/web/MatchActionResourceTest.java
+++ b/src/test/java/net/onrc/onos/core/matchaction/web/MatchActionResourceTest.java
@@ -17,8 +17,8 @@
 
 import net.floodlightcontroller.util.MACAddress;
 import net.onrc.onos.core.matchaction.MatchAction;
+import net.onrc.onos.core.matchaction.MatchActionFloodlightService;
 import net.onrc.onos.core.matchaction.MatchActionId;
-import net.onrc.onos.core.matchaction.MatchActionService;
 import net.onrc.onos.core.matchaction.action.Action;
 import net.onrc.onos.core.matchaction.action.ModifyDstMacAction;
 import net.onrc.onos.core.matchaction.action.OutputAction;
@@ -50,13 +50,16 @@
         Set<MatchAction> matchActionSet = createMatchActions();
 
         // Create a mock match-action service that will return the match-actions
-        MatchActionService matchActionService = createMock(MatchActionService.class);
-        expect(matchActionService.getMatchActions()).andReturn(matchActionSet).anyTimes();
+        MatchActionFloodlightService matchActionService =
+                createMock(MatchActionFloodlightService.class);
+        expect(matchActionService.getMatchActions()).andReturn(matchActionSet)
+                .anyTimes();
         replay(matchActionService);
 
         // Inject the match-action service into a Restlet context
         Map<String, Object> attributes = new HashMap<>();
-        attributes.put(MatchActionService.class.getCanonicalName(), matchActionService);
+        attributes.put(MatchActionFloodlightService.class.getCanonicalName(),
+                matchActionService);
         Context context = new Context();
         context.setAttributes(attributes);
 
@@ -81,8 +84,8 @@
         actions.add(new ModifyDstMacAction(MACAddress.valueOf(10L)));
         actions.add(new OutputAction(PortNumber.uint32(4)));
 
-        MatchAction ma = new MatchAction(new MatchActionId(1L), new SwitchPort(1L, 1L), match,
-                actions);
+        MatchAction ma = new MatchAction(new MatchActionId(1L),
+                new SwitchPort(1L, 1L), match, actions);
 
         matchActionSet.add(ma);