Discard Forward to wrong host

Changed to discard Forward message if the channel does not
match the host that received it.

Change-Id: I9235bd3b0c5eb264f9b1cfe53552fadf66a0edc2
Issue-ID: POLICY-787
Signed-off-by: Jim Hahn <jrh3@att.com>
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/State.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/State.java
index 545c2ef..fcb0e13 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/State.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/State.java
@@ -147,6 +147,11 @@
      * @return the new state, or {@code null} if the state is unchanged
      */
     public State process(Forward msg) {
+        if(!getHost().equals(msg.getChannel())) {
+            logger.info("discard Forward message to {} from {} on topic {}", msg.getChannel(), msg.getSource(), getTopic());
+            return null;
+        }
+        
         logger.info("received Forward message from {} on topic {}", msg.getSource(), getTopic());
         mgr.handle(msg);
         return null;
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java
index 95cbe75..497dbbb 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java
@@ -63,6 +63,7 @@
     @Test
     public void testProcessForward() {
         Forward msg = new Forward();
+        msg.setChannel(MY_HOST);
         assertNull(state.process(msg));
 
         verify(mgr).handle(msg);
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java
index ee4c1ad..01f49b5 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java
@@ -137,7 +137,11 @@
 
     @Test
     public void testProcessForward() {
-        assertNull(state.process(new Forward()));
+        Forward msg = new Forward();
+        msg.setChannel(MY_HOST);
+        assertNull(state.process(msg));
+
+        verify(mgr).handle(msg);
     }
 
     @Test
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java
index 47624aa..cdf9b59 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java
@@ -212,6 +212,11 @@
         Forward msg = new Forward();
         assertNull(state.process(msg));
 
+        verify(mgr, never()).handle(msg);
+
+        msg.setChannel(MY_HOST);
+        assertNull(state.process(msg));
+
         verify(mgr).handle(msg);
     }