### Question:
FingerprintFactory { public synchronized String createFingerprint(final byte[] flowBytes) throws FingerprintException { return createFingerprint(flowBytes, null); } FingerprintFactory(final StringEncryptor encryptor);  FingerprintFactory(final StringEncryptor encryptor, final DocumentBuilder docBuilder); synchronized String createFingerprint(final byte[] flowBytes); synchronized String createFingerprint(final byte[] flowBytes, final FlowController controller); static final String NO_VALUE; }### Answer:
@Test public void testSameFingerprint() throws IOException { final String fp1 = fingerprinter.createFingerprint(getResourceBytes("/nifi/fingerprint/flow1a.xml"), null); final String fp2 = fingerprinter.createFingerprint(getResourceBytes("/nifi/fingerprint/flow1b.xml"), null); assertEquals(fp1, fp2); }
@Test public void testDifferentFingerprint() throws IOException { final String fp1 = fingerprinter.createFingerprint(getResourceBytes("/nifi/fingerprint/flow1a.xml"), null); final String fp2 = fingerprinter.createFingerprint(getResourceBytes("/nifi/fingerprint/flow2.xml"), null); assertNotEquals(fp1, 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")); }
@Test public void testSchemaValidation() throws IOException { FingerprintFactory fp = new FingerprintFactory(null, getValidatingDocumentBuilder()); final String fingerprint = fp.createFingerprint(getResourceBytes("/nifi/fingerprint/validating-flow.xml"), null); }
@Test public void testSameFlowWithDifferentBundleShouldHaveDifferentFingerprints() throws IOException { final String fp1 = fingerprinter.createFingerprint(getResourceBytes("/nifi/fingerprint/flow3-with-bundle-1.xml"), null); assertTrue(fp1.contains("org.apache.nifinifi-standard-nar1.0")); final String fp2 = fingerprinter.createFingerprint(getResourceBytes("/nifi/fingerprint/flow3-with-bundle-2.xml"), null); assertTrue(fp2.contains("org.apache.nifinifi-standard-nar2.0")); assertNotEquals(fp1, fp2); }
@Test public void testSameFlowAndOneHasNoBundleShouldHaveDifferentFingerprints() throws IOException { final String fp1 = fingerprinter.createFingerprint(getResourceBytes("/nifi/fingerprint/flow3-with-bundle-1.xml"), null); assertTrue(fp1.contains("org.apache.nifinifi-standard-nar1.0")); final String fp2 = fingerprinter.createFingerprint(getResourceBytes("/nifi/fingerprint/flow3-with-no-bundle.xml"), null); assertTrue(fp2.contains("MISSING_BUNDLE")); assertNotEquals(fp1, fp2); }
@Test public void testSameFlowAndOneHasMissingBundleShouldHaveDifferentFingerprints() throws IOException { final String fp1 = fingerprinter.createFingerprint(getResourceBytes("/nifi/fingerprint/flow3-with-bundle-1.xml"), null); assertTrue(fp1.contains("org.apache.nifinifi-standard-nar1.0")); final String fp2 = fingerprinter.createFingerprint(getResourceBytes("/nifi/fingerprint/flow3-with-missing-bundle.xml"), null); assertTrue(fp2.contains("missingmissingmissing")); assertNotEquals(fp1, fp2); }