diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/RemoteProcessGroupEntityMerger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/RemoteProcessGroupEntityMerger.java index 5207524e23..d210873999 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/RemoteProcessGroupEntityMerger.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/RemoteProcessGroupEntityMerger.java @@ -23,6 +23,7 @@ import org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO; import org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO; import org.apache.nifi.web.api.entity.RemoteProcessGroupEntity; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -124,11 +125,20 @@ public class RemoteProcessGroupEntityMerger implements ComponentEntityMerger inputs1 = new HashSet<>(); + inputs1.add(in1_1); + inputs1.add(in1_2); + + final RemoteProcessGroupPortDTO out1_1 = new RemoteProcessGroupPortDTO(); + out1_1.setName("out1"); + + final Set outputs1 = new HashSet<>(); + outputs1.add(out1_1); + + final RemoteProcessGroupContentsDTO contents1 = new RemoteProcessGroupContentsDTO(); + contents1.setInputPorts(inputs1); + contents1.setOutputPorts(outputs1); + + final RemoteProcessGroupDTO rpg1 = new RemoteProcessGroupDTO(); + rpg1.setContents(contents1); + rpg1.setInputPortCount(2); + rpg1.setOutputPortCount(1); + + final RemoteProcessGroupEntity entity1 = new RemoteProcessGroupEntity(); + entity1.setPermissions(permissions); + entity1.setOperatePermissions(opsPermissions); + entity1.setStatus(status); + entity1.setComponent(rpg1); + + final Set inputs2 = new HashSet<>(); + final Set outputs2 = new HashSet<>(); + + final RemoteProcessGroupContentsDTO contents2 = new RemoteProcessGroupContentsDTO(); + contents2.setInputPorts(inputs2); + contents2.setOutputPorts(outputs2); + + final RemoteProcessGroupDTO rpg2 = new RemoteProcessGroupDTO(); + rpg2.setContents(contents2); + rpg2.setInputPortCount(0); + rpg2.setOutputPortCount(0); + + final RemoteProcessGroupEntity entity2 = new RemoteProcessGroupEntity(); + entity2.setPermissions(permissions); + entity2.setOperatePermissions(opsPermissions); + entity2.setStatus(status); + entity2.setComponent(rpg2); + + final Map nodeMap = new HashMap<>(); + nodeMap.put(node1, entity1); + nodeMap.put(node2, entity2); + + final RemoteProcessGroupEntityMerger merger = new RemoteProcessGroupEntityMerger(); + merger.merge(entity1, nodeMap); + + // should only include ports in common to all rpg's + assertEquals(0, entity1.getComponent().getContents().getInputPorts().size()); + assertEquals(0, entity1.getComponent().getContents().getOutputPorts().size()); + assertEquals(0, entity1.getComponent().getInputPortCount().intValue()); + assertEquals(0, entity1.getComponent().getOutputPortCount().intValue()); + } }