Changes related to the "LinkCollectionIntent" type of intents
(e.g., Multipoint-to-singlepoint and Singlepoint-to-multipoint)

* Apply the Intent-defined traffic treatment only on the flowmods
  on the ingress switch with ingress inport for a flowmod.
  Previously, the traffic treatments were applied on each switch,
  and semantically it is not the correct (default) behavior.

* Express the flowmods by explicitly specifying the expected inport
  in the matching conditions for each flowmod.
  Previously, the inport was not included in the matching conditions.

Change-Id: Iefe3e88f7b6257c18fd6f99c2740feabbe8eedc5
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/MultiPointToSinglePointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/MultiPointToSinglePointIntentCompiler.java
index 6fb94c9..825dc57 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/MultiPointToSinglePointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/MultiPointToSinglePointIntentCompiler.java
@@ -16,6 +16,7 @@
 package org.onosproject.net.intent.impl;
 
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -39,6 +40,7 @@
 import org.onosproject.net.resource.LinkResourceAllocations;
 import org.onosproject.net.topology.PathService;
 
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 
 /**
@@ -75,8 +77,10 @@
             for (Link link : path.links()) {
                 if (links.containsKey(link.src().deviceId())) {
                     // We've already reached the existing tree with the first
-                    // part of this path. Don't add the remainder of the path
+                    // part of this path. Add the merging point with differen
+                    // incoming port, but don't add the remainder of the path
                     // in case it differs from the path we already have.
+                    links.put(link.src().deviceId(), link);
                     break;
                 }
 
@@ -86,7 +90,10 @@
 
         Intent result = new LinkCollectionIntent(intent.appId(),
                                                  intent.selector(), intent.treatment(),
-                                                 Sets.newHashSet(links.values()), intent.egressPoint());
+                                                 Sets.newHashSet(links.values()),
+                                                 intent.ingressPoints(),
+                                                 ImmutableSet.of(intent.egressPoint()),
+                                                 Collections.emptyList());
         return Arrays.asList(result);
     }