IntentPushTestCommand: ignore IntentEvent submitted by others

- Note: command must specify non-overlapping appId using
  4th and 5th arguments

Change-Id: I4dcfe57fc1d3de63c47e88d99d647b48ab80d86c
diff --git a/cli/src/main/java/org/onosproject/cli/net/IntentPushTestCommand.java b/cli/src/main/java/org/onosproject/cli/net/IntentPushTestCommand.java
index 7ee207c..03fd79e 100644
--- a/cli/src/main/java/org/onosproject/cli/net/IntentPushTestCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/IntentPushTestCommand.java
@@ -17,6 +17,7 @@
 
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Lists;
+
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.commands.Option;
@@ -41,7 +42,9 @@
 import org.onlab.packet.MacAddress;
 
 import java.util.EnumSet;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
@@ -100,6 +103,7 @@
     private int appIdBase;
     private int count;
     private boolean add;
+    private final Set<ApplicationId> myAppIds = new HashSet<>();
 
     @Override
     protected void execute() {
@@ -153,7 +157,7 @@
         for (int app = 0; app < apps; app++) {
             for (int i = 1; i <= intentsPerApp; i++) {
                 TrafficSelector s = selector
-                        .matchEthSrc(MacAddress.valueOf(i + app * intentsPerApp))
+                        .matchEthSrc(MacAddress.valueOf(i + (app + appIdBase) * intentsPerApp))
                         .build();
                 intents.put(app, new PointToPointIntent(appId(app), s, treatment,
                                                         ingress, egress));
@@ -204,8 +208,11 @@
      * @return command-line application identifier
      */
     protected ApplicationId appId(Integer id) {
-        return get(CoreService.class).registerApplication("org.onosproject.cli-"
-                                                                  + (id + appIdBase));
+        ApplicationId appId = get(CoreService.class)
+                                .registerApplication("org.onosproject.cli-"
+                                                     + (id + appIdBase));
+        myAppIds.add(appId);
+        return appId;
     }
 
     /**
@@ -240,6 +247,10 @@
             = EnumSet.of(Type.INSTALL_REQ, Type.WITHDRAW_REQ);
     @Override
     public synchronized void event(IntentEvent event) {
+        if (!myAppIds.contains(event.subject().appId())) {
+            // not my event, ignore
+            return;
+        }
         Type expected = add ? Type.INSTALLED : Type.WITHDRAWN;
         if (event.type() == expected) {
             end = Math.max(end, event.time());