This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 079276be42 NIFI-14435 Revert Add Nested Process Group Changes in Flow
Comparison with Deep Strategy
079276be42 is described below
commit 079276be424660504c572ad238a311e8dffa97b6
Author: exceptionfactory <[email protected]>
AuthorDate: Tue Apr 8 20:42:21 2025 -0500
NIFI-14435 Revert Add Nested Process Group Changes in Flow Comparison with
Deep Strategy
Changes break StandardNiFiServiceFacade.getComponentsAffectedByFlowUpdate()
casting to InstantiatedVersionedComponent
This reverts commit 5bf71758ae12d04df5a6f165216e9256f0ec32d3.
Signed-off-by: David Handermann <[email protected]>
---
.../flow/diff/FlowComparatorVersionedStrategy.java | 3 +-
.../registry/flow/diff/StandardFlowComparator.java | 28 +++----
.../flow/diff/TestStandardFlowComparator.java | 90 ----------------------
3 files changed, 11 insertions(+), 110 deletions(-)
diff --git
a/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/FlowComparatorVersionedStrategy.java
b/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/FlowComparatorVersionedStrategy.java
index 1566065e07..73f7346620 100644
---
a/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/FlowComparatorVersionedStrategy.java
+++
b/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/FlowComparatorVersionedStrategy.java
@@ -26,8 +26,7 @@ public enum FlowComparatorVersionedStrategy {
*/
DEEP,
/**
- * The comparator should disregard individual changes but only look for
changes
- * in the version information.
+ * The comparator should disregard individual changes but only look for
changes in the version information.
*/
SHALLOW
}
diff --git
a/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java
b/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java
index b989c3903b..b2e4adb337 100644
---
a/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java
+++
b/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java
@@ -147,29 +147,11 @@ public class StandardFlowComparator implements
FlowComparator {
final boolean compareName, final boolean comparePos, final boolean
compareComments) {
if (componentA == null) {
differences.add(difference(DifferenceType.COMPONENT_ADDED,
componentA, componentB, componentA, componentB));
-
- if (flowComparatorVersionedStrategy ==
FlowComparatorVersionedStrategy.DEEP
- && componentB instanceof VersionedProcessGroup groupB) {
- // we want to also add the differences of the sub process
groups
- // to do that we create an empty process group to simulate
groupA
- // and compare it to groupB
- compare(new VersionedProcessGroup(), groupB, differences,
comparePos);
- }
-
return true;
}
if (componentB == null) {
differences.add(difference(DifferenceType.COMPONENT_REMOVED,
componentA, componentB, componentA, componentB));
-
- if (flowComparatorVersionedStrategy ==
FlowComparatorVersionedStrategy.DEEP
- && componentA instanceof VersionedProcessGroup groupA) {
- // we want to also add the differences of the sub process
groups
- // to do that we create an empty process group to simulate
groupA
- // and compare it to groupB
- compare(groupA, new VersionedProcessGroup(), differences,
comparePos);
- }
-
return true;
}
@@ -547,6 +529,16 @@ public class StandardFlowComparator implements
FlowComparator {
return;
}
+ if (groupA == null) {
+ differences.add(difference(DifferenceType.COMPONENT_ADDED, groupA,
groupB, groupA, groupB));
+ return;
+ }
+
+ if (groupB == null) {
+ differences.add(difference(DifferenceType.COMPONENT_REMOVED,
groupA, groupB, groupA, groupB));
+ return;
+ }
+
// Compare Flow Coordinates for any differences. Because the way in
which we store flow coordinates has changed between versions,
// we have to use a specific method for this instead of just using
addIfDifferent. We also store the differences into a different set
// so that we can later check if there were any differences or not.
diff --git
a/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/test/java/org/apache/nifi/registry/flow/diff/TestStandardFlowComparator.java
b/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/test/java/org/apache/nifi/registry/flow/diff/TestStandardFlowComparator.java
index 0b1e6de026..75206ad55d 100644
---
a/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/test/java/org/apache/nifi/registry/flow/diff/TestStandardFlowComparator.java
+++
b/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/test/java/org/apache/nifi/registry/flow/diff/TestStandardFlowComparator.java
@@ -17,14 +17,11 @@
package org.apache.nifi.registry.flow.diff;
-import org.apache.nifi.flow.ComponentType;
import org.apache.nifi.flow.VersionedAsset;
import org.apache.nifi.flow.VersionedComponent;
-import org.apache.nifi.flow.VersionedControllerService;
import org.apache.nifi.flow.VersionedParameter;
import org.apache.nifi.flow.VersionedParameterContext;
import org.apache.nifi.flow.VersionedProcessGroup;
-import org.apache.nifi.flow.VersionedProcessor;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -40,7 +37,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestStandardFlowComparator {
private Map<String, String> decryptedToEncrypted;
@@ -180,92 +176,6 @@ public class TestStandardFlowComparator {
assertEquals(4, differences.size());
}
- @Test
- public void testDeepStrategyWithChildPGs() {
- final Function<String, String> decryptor = encryptedToDecrypted::get;
-
- final VersionedProcessGroup rootPGA = new VersionedProcessGroup();
- rootPGA.setIdentifier("rootPG");
-
- final VersionedProcessGroup rootPGB = new VersionedProcessGroup();
- rootPGB.setIdentifier("rootPG");
- final VersionedProcessGroup childPG = new VersionedProcessGroup();
- childPG.setIdentifier("childPG");
- rootPGB.getProcessGroups().add(childPG);
- final VersionedProcessGroup subChildPG = new VersionedProcessGroup();
- subChildPG.setIdentifier("subChildPG");
- childPG.getProcessGroups().add(subChildPG);
- final VersionedProcessor processor = new VersionedProcessor();
- processor.setIdentifier("processor");
- childPG.getProcessors().add(processor);
- final VersionedControllerService controllerService = new
VersionedControllerService();
- controllerService.setIdentifier("controllerService");
- subChildPG.getControllerServices().add(controllerService);
-
- final ComparableDataFlow flowA = new StandardComparableDataFlow("Flow
A", rootPGA);
- final ComparableDataFlow flowB = new StandardComparableDataFlow("Flow
B", rootPGB);
-
- // Testing when a child PG is added and the child PG contains
components
-
- comparator = new StandardFlowComparator(flowA, flowB,
Collections.emptySet(),
- new StaticDifferenceDescriptor(), decryptor,
VersionedComponent::getIdentifier, FlowComparatorVersionedStrategy.SHALLOW);
-
- final Set<FlowDifference> diffShallowChildPgAdded =
comparator.compare().getDifferences();
- assertEquals(1, diffShallowChildPgAdded.size());
- assertTrue(diffShallowChildPgAdded.stream()
- .anyMatch(difference -> difference.getDifferenceType() ==
DifferenceType.COMPONENT_ADDED
- && difference.getComponentB().getComponentType() ==
ComponentType.PROCESS_GROUP));
-
- comparator = new StandardFlowComparator(flowA, flowB,
Collections.emptySet(),
- new StaticDifferenceDescriptor(), decryptor,
VersionedComponent::getIdentifier, FlowComparatorVersionedStrategy.DEEP);
- final Set<FlowDifference> diffDeepChildPgAdded =
comparator.compare().getDifferences();
- assertEquals(4, diffDeepChildPgAdded.size());
- assertTrue(diffDeepChildPgAdded.stream()
- .anyMatch(difference -> difference.getDifferenceType() ==
DifferenceType.COMPONENT_ADDED
- && difference.getComponentB().getComponentType() ==
ComponentType.PROCESS_GROUP
- &&
difference.getComponentB().getIdentifier().equals("childPG")));
- assertTrue(diffDeepChildPgAdded.stream()
- .anyMatch(difference -> difference.getDifferenceType() ==
DifferenceType.COMPONENT_ADDED
- && difference.getComponentB().getComponentType() ==
ComponentType.PROCESS_GROUP
- &&
difference.getComponentB().getIdentifier().equals("subChildPG")));
- assertTrue(diffDeepChildPgAdded.stream()
- .anyMatch(difference -> difference.getDifferenceType() ==
DifferenceType.COMPONENT_ADDED
- && difference.getComponentB().getComponentType() ==
ComponentType.PROCESSOR));
- assertTrue(diffDeepChildPgAdded.stream()
- .anyMatch(difference -> difference.getDifferenceType() ==
DifferenceType.COMPONENT_ADDED
- && difference.getComponentB().getComponentType() ==
ComponentType.CONTROLLER_SERVICE));
-
- // Testing when a child PG is removed and the child PG contains
components
-
- comparator = new StandardFlowComparator(flowB, flowA,
Collections.emptySet(),
- new StaticDifferenceDescriptor(), decryptor,
VersionedComponent::getIdentifier, FlowComparatorVersionedStrategy.SHALLOW);
-
- final Set<FlowDifference> diffShallowChildPgRemoved =
comparator.compare().getDifferences();
- assertEquals(1, diffShallowChildPgRemoved.size());
- assertTrue(diffShallowChildPgRemoved.stream()
- .anyMatch(difference -> difference.getDifferenceType() ==
DifferenceType.COMPONENT_REMOVED
- && difference.getComponentA().getComponentType() ==
ComponentType.PROCESS_GROUP));
-
- comparator = new StandardFlowComparator(flowB, flowA,
Collections.emptySet(),
- new StaticDifferenceDescriptor(), decryptor,
VersionedComponent::getIdentifier, FlowComparatorVersionedStrategy.DEEP);
- final Set<FlowDifference> diffDeepChildPgRemoved =
comparator.compare().getDifferences();
- assertEquals(4, diffDeepChildPgRemoved.size());
- assertTrue(diffDeepChildPgRemoved.stream()
- .anyMatch(difference -> difference.getDifferenceType() ==
DifferenceType.COMPONENT_REMOVED
- && difference.getComponentA().getComponentType() ==
ComponentType.PROCESS_GROUP
- &&
difference.getComponentA().getIdentifier().equals("childPG")));
- assertTrue(diffDeepChildPgRemoved.stream()
- .anyMatch(difference -> difference.getDifferenceType() ==
DifferenceType.COMPONENT_REMOVED
- && difference.getComponentA().getComponentType() ==
ComponentType.PROCESS_GROUP
- &&
difference.getComponentA().getIdentifier().equals("subChildPG")));
- assertTrue(diffDeepChildPgRemoved.stream()
- .anyMatch(difference -> difference.getDifferenceType() ==
DifferenceType.COMPONENT_REMOVED
- && difference.getComponentA().getComponentType() ==
ComponentType.PROCESSOR));
- assertTrue(diffDeepChildPgRemoved.stream()
- .anyMatch(difference -> difference.getDifferenceType() ==
DifferenceType.COMPONENT_REMOVED
- && difference.getComponentA().getComponentType() ==
ComponentType.CONTROLLER_SERVICE));
- }
-
private VersionedParameter createParameter(final String name, final String
value, final boolean sensitive) {
return createParameter(name, value, sensitive, null);
}