From 4f2d17a8d4a8a674cd22bf9df68f9d64bff93b92 Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Wed, 6 Jul 2016 14:35:51 -0400 Subject: [PATCH] NIFI-2159: Fixed bug that caused relationship names not to get added to fingerprint This closes #612 Signed-off-by: jpercivall --- .../apache/nifi/fingerprint/FingerprintFactory.java | 10 +++------- .../nifi/fingerprint/FingerprintFactoryTest.java | 9 +++++++++ .../src/test/resources/nifi/fingerprint/flow1a.xml | 2 +- .../src/test/resources/nifi/fingerprint/flow1b.xml | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/fingerprint/FingerprintFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/fingerprint/FingerprintFactory.java index be58d22e7b..26f83b5ffd 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/fingerprint/FingerprintFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/fingerprint/FingerprintFactory.java @@ -856,11 +856,13 @@ public final class FingerprintFactory { // destination type appendFirstValue(builder, DomUtils.getChildNodesByTagName(connectionElem, "destinationType")); + appendFirstValue(builder, DomUtils.getChildNodesByTagName(connectionElem, "name")); + // relationships final NodeList relationshipElems = DomUtils.getChildNodesByTagName(connectionElem, "relationship"); final List sortedRelationshipElems = sortElements(relationshipElems, getConnectionRelationshipsComparator()); for (final Element relationshipElem : sortedRelationshipElems) { - addConnectionRelationshipFingerprint(builder, relationshipElem); + builder.append(getValue(relationshipElem, "NO_VALUE")); } return builder; @@ -885,12 +887,6 @@ public final class FingerprintFactory { return builder; } - private StringBuilder addConnectionRelationshipFingerprint(final StringBuilder builder, final Element relationshipElem) throws FingerprintException { - // destination type - appendFirstValue(builder, DomUtils.getChildNodesByTagName(relationshipElem, "relationship")); - return builder; - } - private StringBuilder addFunnelFingerprint(final StringBuilder builder, final Element funnelElem) throws FingerprintException { // id appendFirstValue(builder, DomUtils.getChildNodesByTagName(funnelElem, "id")); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/fingerprint/FingerprintFactoryTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/fingerprint/FingerprintFactoryTest.java index ae9624bbe2..bb12e7842c 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/fingerprint/FingerprintFactoryTest.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/fingerprint/FingerprintFactoryTest.java @@ -18,10 +18,12 @@ package org.apache.nifi.fingerprint; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.io.IOException; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Test; @@ -52,6 +54,13 @@ public class FingerprintFactoryTest { assertFalse(fp1.equals(fp2)); } + @Test + public void testResourceValueInFingerprint() throws IOException { + final String fingerprint = fingerprinter.createFingerprint(getResourceBytes("/nifi/fingerprint/flow1a.xml"), null); + assertEquals(3, StringUtils.countMatches(fingerprint, "success")); + assertTrue(fingerprint.contains("In Connection")); + } + private byte[] getResourceBytes(final String resource) throws IOException { return IOUtils.toByteArray(FingerprintFactoryTest.class.getResourceAsStream(resource)); } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/nifi/fingerprint/flow1a.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/nifi/fingerprint/flow1a.xml index 81835df80e..beccdccf26 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/nifi/fingerprint/flow1a.xml +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/nifi/fingerprint/flow1a.xml @@ -89,7 +89,7 @@ b25c3c8f-8dfe-4dda-950e-b6edfb6c99f4 - In + In Connection 1 0 diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/nifi/fingerprint/flow1b.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/nifi/fingerprint/flow1b.xml index 4f18156e8b..19ed079370 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/nifi/fingerprint/flow1b.xml +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/nifi/fingerprint/flow1b.xml @@ -89,7 +89,7 @@ b25c3c8f-8dfe-4dda-950e-b6edfb6c99f4 - In + In Connection 1 0