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 52d1e349ed NIFI-15346 Added unit tests property migration in Box, CDC,
Cipher, Confluent, Dropbox Bundles (#10651)
52d1e349ed is described below
commit 52d1e349edeffae0945a25d0fbe405182f4ee702
Author: dan-s1 <[email protected]>
AuthorDate: Fri Dec 19 21:50:36 2025 -0500
NIFI-15346 Added unit tests property migration in Box, CDC, Cipher,
Confluent, Dropbox Bundles (#10651)
Signed-off-by: David Handermann <[email protected]>
---
.../nifi/processors/box/FetchBoxFileTest.java | 21 +++++-
.../nifi/processors/box/ListBoxFileTest.java | 25 ++++--
.../apache/nifi/processors/box/PutBoxFileTest.java | 18 +++++
...nConfigBasedBoxClientServiceTestRunnerTest.java | 39 ++++++++--
.../mysql/processors/CaptureChangeMySQLTest.java | 62 +++++++++++----
.../processors/cipher/VerifyContentMACTest.java | 16 ++++
.../ConfluentSchemaRegistryTest.java | 36 ++++++++-
.../dropbox/TestDropboxProcessorMigration.java | 88 ++++++++++++++++++++++
.../StandardDropboxCredentialServiceTest.java | 54 +++++++++++++
9 files changed, 325 insertions(+), 34 deletions(-)
diff --git
a/nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/FetchBoxFileTest.java
b/nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/FetchBoxFileTest.java
index 726cc21ea9..b65ca4fce0 100644
---
a/nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/FetchBoxFileTest.java
+++
b/nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/FetchBoxFileTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.nifi.processors.box;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -28,6 +29,7 @@ import java.util.List;
import java.util.Map;
import org.apache.nifi.provenance.ProvenanceEventType;
import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.PropertyMigrationResult;
import org.apache.nifi.util.TestRunners;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -73,7 +75,7 @@ public class FetchBoxFileTest extends AbstractBoxFileTest {
testRunner.assertAllFlowFilesTransferred(FetchBoxFile.REL_SUCCESS, 1);
final List<MockFlowFile> flowFiles =
testRunner.getFlowFilesForRelationship(FetchBoxFile.REL_SUCCESS);
- final MockFlowFile ff0 = flowFiles.get(0);
+ final MockFlowFile ff0 = flowFiles.getFirst();
assertOutFlowFileAttributes(ff0);
verify(mockBoxFile).download(any(OutputStream.class));
assertProvenanceEvent(ProvenanceEventType.FETCH);
@@ -94,14 +96,14 @@ public class FetchBoxFileTest extends AbstractBoxFileTest {
testRunner.assertAllFlowFilesTransferred(FetchBoxFile.REL_SUCCESS, 1);
final List<MockFlowFile> flowFiles =
testRunner.getFlowFilesForRelationship(FetchBoxFile.REL_SUCCESS);
- final MockFlowFile ff0 = flowFiles.get(0);
+ final MockFlowFile ff0 = flowFiles.getFirst();
assertOutFlowFileAttributes(ff0);
verify(mockBoxFile).download(any(OutputStream.class));
assertProvenanceEvent(ProvenanceEventType.FETCH);
}
@Test
- void testFileDownloadFailure() {
+ void testFileDownloadFailure() {
testRunner.setProperty(FetchBoxFile.FILE_ID, TEST_FILE_ID);
doThrow(new RuntimeException("Download
failed")).when(mockBoxFile).download(any(OutputStream.class));
@@ -114,8 +116,19 @@ public class FetchBoxFileTest extends AbstractBoxFileTest {
testRunner.assertAllFlowFilesTransferred(FetchBoxFile.REL_FAILURE, 1);
final List<MockFlowFile> flowFiles =
testRunner.getFlowFilesForRelationship(FetchBoxFile.REL_FAILURE);
- final MockFlowFile ff0 = flowFiles.get(0);
+ final MockFlowFile ff0 = flowFiles.getFirst();
ff0.assertAttributeEquals(BoxFileAttributes.ERROR_MESSAGE, "Download
failed");
assertNoProvenanceEvent();
}
+
+ @Test
+ void testMigration() {
+ final Map<String, String> expected = Map.ofEntries(
+
Map.entry(AbstractBoxProcessor.OLD_BOX_CLIENT_SERVICE_PROPERTY_NAME,
AbstractBoxProcessor.BOX_CLIENT_SERVICE.getName()),
+ Map.entry("box-file-id", FetchBoxFile.FILE_ID.getName())
+ );
+
+ final PropertyMigrationResult propertyMigrationResult =
testRunner.migrateProperties();
+ assertEquals(expected, propertyMigrationResult.getPropertiesRenamed());
+ }
}
diff --git
a/nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/ListBoxFileTest.java
b/nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/ListBoxFileTest.java
index a1ce8bfe5c..ae1636bdbd 100644
---
a/nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/ListBoxFileTest.java
+++
b/nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/ListBoxFileTest.java
@@ -27,9 +27,12 @@ import com.box.sdk.BoxFolder;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.json.JsonRecordSetWriter;
+import org.apache.nifi.processor.util.list.AbstractListProcessor;
+import org.apache.nifi.processor.util.list.ListedEntityTracker;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.serialization.RecordSetWriterFactory;
import org.apache.nifi.util.MockFlowFile;
@@ -106,11 +109,23 @@ public class ListBoxFileTest extends AbstractBoxFileTest
implements FileListingT
void testMigration() {
TestRunner runner = TestRunners.newTestRunner(ListBoxFile.class);
final PropertyMigrationResult propertyMigrationResult =
runner.migrateProperties();
- // NOTE: Only ensuring migration of property defined outside of this
class.
- final Map<String, String> expectedRenamed =
-
Map.of(AbstractBoxProcessor.OLD_BOX_CLIENT_SERVICE_PROPERTY_NAME,
AbstractBoxProcessor.BOX_CLIENT_SERVICE.getName());
-
- expectedRenamed.forEach((key, value) -> assertEquals(value,
propertyMigrationResult.getPropertiesRenamed().get(key)));
+ final Map<String, String> expectedRenamed = Map.ofEntries(
+
Map.entry(AbstractBoxProcessor.OLD_BOX_CLIENT_SERVICE_PROPERTY_NAME,
AbstractBoxProcessor.BOX_CLIENT_SERVICE.getName()),
+ Map.entry("box-folder-id", ListBoxFile.FOLDER_ID.getName()),
+ Map.entry("recursive-search",
ListBoxFile.RECURSIVE_SEARCH.getName()),
+ Map.entry("min-age", ListBoxFile.MIN_AGE.getName()),
+
Map.entry(ListedEntityTracker.OLD_TRACKING_STATE_CACHE_PROPERTY_NAME,
ListBoxFile.TRACKING_STATE_CACHE.getName()),
+
Map.entry(ListedEntityTracker.OLD_TRACKING_TIME_WINDOW_PROPERTY_NAME,
ListBoxFile.TRACKING_TIME_WINDOW.getName()),
+
Map.entry(ListedEntityTracker.OLD_INITIAL_LISTING_TARGET_PROPERTY_NAME,
ListBoxFile.INITIAL_LISTING_TARGET.getName()),
+ Map.entry("target-system-timestamp-precision",
AbstractListProcessor.TARGET_SYSTEM_TIMESTAMP_PRECISION.getName()),
+ Map.entry("listing-strategy",
AbstractListProcessor.LISTING_STRATEGY.getName()),
+ Map.entry("record-writer",
AbstractListProcessor.RECORD_WRITER.getName())
+ );
+
+ assertEquals(expectedRenamed,
propertyMigrationResult.getPropertiesRenamed());
+
+ final Set<String> expectedRemoved = Set.of("Distributed Cache
Service");
+ assertEquals(expectedRemoved,
propertyMigrationResult.getPropertiesRemoved());
}
private void addJsonRecordWriterFactory() throws InitializationException {
diff --git
a/nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/PutBoxFileTest.java
b/nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/PutBoxFileTest.java
index 7507c2aeda..1c1032cbd3 100644
---
a/nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/PutBoxFileTest.java
+++
b/nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/PutBoxFileTest.java
@@ -21,6 +21,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
@@ -35,6 +36,7 @@ import java.util.Map;
import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.provenance.ProvenanceEventType;
import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.PropertyMigrationResult;
import org.apache.nifi.util.TestRunners;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -210,4 +212,20 @@ public class PutBoxFileTest extends AbstractBoxFileTest {
ff0.assertAttributeEquals(BoxFileAttributes.ERROR_MESSAGE, "Upload
error");
assertNoProvenanceEvent();
}
+
+ @Test
+ void testMigration() {
+ final Map<String, String> expected = Map.ofEntries(
+
Map.entry(AbstractBoxProcessor.OLD_BOX_CLIENT_SERVICE_PROPERTY_NAME,
AbstractBoxProcessor.BOX_CLIENT_SERVICE.getName()),
+ Map.entry("box-folder-id", PutBoxFile.FOLDER_ID.getName()),
+ Map.entry("file-name", PutBoxFile.FILE_NAME.getName()),
+ Map.entry("subfolder-name",
PutBoxFile.SUBFOLDER_NAME.getName()),
+ Map.entry("create-folder",
PutBoxFile.CREATE_SUBFOLDER.getName()),
+ Map.entry("conflict-resolution-strategy",
PutBoxFile.CONFLICT_RESOLUTION.getName()),
+ Map.entry("chunked-upload-threshold",
PutBoxFile.CHUNKED_UPLOAD_THRESHOLD.getName())
+ );
+
+ final PropertyMigrationResult propertyMigrationResult =
testRunner.migrateProperties();
+ assertEquals(expected, propertyMigrationResult.getPropertiesRenamed());
+ }
}
diff --git
a/nifi-extension-bundles/nifi-box-bundle/nifi-box-services/src/test/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientServiceTestRunnerTest.java
b/nifi-extension-bundles/nifi-box-bundle/nifi-box-services/src/test/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientServiceTestRunnerTest.java
index 28b7208d62..fe6a5c08ec 100644
---
a/nifi-extension-bundles/nifi-box-bundle/nifi-box-services/src/test/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientServiceTestRunnerTest.java
+++
b/nifi-extension-bundles/nifi-box-bundle/nifi-box-services/src/test/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientServiceTestRunnerTest.java
@@ -16,13 +16,18 @@
*/
package org.apache.nifi.box.controllerservices;
-import org.apache.nifi.processor.Processor;
+import org.apache.nifi.proxy.ProxyConfigurationService;
+import org.apache.nifi.util.MockPropertyConfiguration;
+import org.apache.nifi.util.NoOpProcessor;
+import org.apache.nifi.util.PropertyMigrationResult;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import static org.mockito.Mockito.mock;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class JsonConfigBasedBoxClientServiceTestRunnerTest {
private JsonConfigBasedBoxClientService testSubject;
@@ -31,10 +36,7 @@ public class JsonConfigBasedBoxClientServiceTestRunnerTest {
@BeforeEach
void setUp() throws Exception {
testSubject = new JsonConfigBasedBoxClientService();
-
- Processor dummyProcessor = mock(Processor.class);
- testRunner = TestRunners.newTestRunner(dummyProcessor);
-
+ testRunner = TestRunners.newTestRunner(NoOpProcessor.class);
testRunner.addControllerService(testSubject.getClass().getSimpleName(),
testSubject);
}
@@ -134,4 +136,29 @@ public class JsonConfigBasedBoxClientServiceTestRunnerTest
{
testRunner.setProperty(testSubject,
JsonConfigBasedBoxClientService.READ_TIMEOUT, "1234");
testRunner.assertNotValid(testSubject);
}
+
+ @Test
+ void testMigration() {
+ final Map<String, String> propertyValues = Map.of(
+ JsonConfigBasedBoxClientService.ACCOUNT_ID.getName(),
"account_id",
+ JsonConfigBasedBoxClientService.CONNECT_TIMEOUT.getName(), "1
min",
+ JsonConfigBasedBoxClientService.READ_TIMEOUT.getName(), "1234"
+ );
+
+ final MockPropertyConfiguration configuration = new
MockPropertyConfiguration(propertyValues);
+ final JsonConfigBasedBoxClientService jsonConfigBasedBoxClientService
= new JsonConfigBasedBoxClientService();
+ jsonConfigBasedBoxClientService.migrateProperties(configuration);
+
+ Map<String, String> expected = Map.ofEntries(
+ Map.entry("box-account-id",
JsonConfigBasedBoxClientService.ACCOUNT_ID.getName()),
+ Map.entry("app-config-file",
JsonConfigBasedBoxClientService.APP_CONFIG_FILE.getName()),
+ Map.entry("app-config-json",
JsonConfigBasedBoxClientService.APP_CONFIG_JSON.getName()),
+
Map.entry(ProxyConfigurationService.OBSOLETE_PROXY_CONFIGURATION_SERVICE,
ProxyConfigurationService.PROXY_CONFIGURATION_SERVICE.getName())
+ );
+
+ final PropertyMigrationResult result =
configuration.toPropertyMigrationResult();
+ final Map<String, String> propertiesRenamed =
result.getPropertiesRenamed();
+
+ assertEquals(expected, propertiesRenamed);
+ }
}
diff --git
a/nifi-extension-bundles/nifi-cdc/nifi-cdc-mysql-bundle/nifi-cdc-mysql-processors/src/test/java/org/apache/nifi/cdc/mysql/processors/CaptureChangeMySQLTest.java
b/nifi-extension-bundles/nifi-cdc/nifi-cdc-mysql-bundle/nifi-cdc-mysql-processors/src/test/java/org/apache/nifi/cdc/mysql/processors/CaptureChangeMySQLTest.java
index db73f049f8..43ba655d40 100644
---
a/nifi-extension-bundles/nifi-cdc/nifi-cdc-mysql-bundle/nifi-cdc-mysql-processors/src/test/java/org/apache/nifi/cdc/mysql/processors/CaptureChangeMySQLTest.java
+++
b/nifi-extension-bundles/nifi-cdc/nifi-cdc-mysql-bundle/nifi-cdc-mysql-processors/src/test/java/org/apache/nifi/cdc/mysql/processors/CaptureChangeMySQLTest.java
@@ -49,6 +49,7 @@ import org.apache.nifi.provenance.ProvenanceEventType;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.ssl.SSLContextService;
import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.PropertyMigrationResult;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.jupiter.api.BeforeEach;
@@ -70,6 +71,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Set;
import java.util.concurrent.TimeoutException;
import java.util.stream.IntStream;
@@ -86,8 +88,8 @@ import static org.mockito.Mockito.when;
*/
@ExtendWith(MockitoExtension.class)
public class CaptureChangeMySQLTest {
- // Use an http-based URL driver location because we don't have the driver
available in the unit test, and we don't want the processor to
- // be invalid due to a missing file. By specifying an HTTP based URL
address, we won't validate whether or not the file exists
+ // Use a http-based URL driver location because we don't have the driver
available in the unit test, and we don't want the processor to
+ // be invalid due to a missing file. By specifying an HTTP based URL
address, we won't validate whether the file exists
private static final String DRIVER_LOCATION =
"http://mysql-driver.com/driver.jar";
private static final String LOCAL_HOST = "localhost";
private static final int DEFAULT_PORT = 3306;
@@ -283,9 +285,9 @@ public class CaptureChangeMySQLTest {
List<MockFlowFile> resultFiles =
testRunner.getFlowFilesForRelationship(CaptureChangeMySQL.REL_SUCCESS);
assertEquals(1, resultFiles.size());
- assertEquals(TEN,
resultFiles.get(0).getAttribute(EventWriter.SEQUENCE_ID_KEY));
+ assertEquals(TEN,
resultFiles.getFirst().getAttribute(EventWriter.SEQUENCE_ID_KEY));
// Verify the contents of the event includes the database and table
name even though the cache is not configured
- Map<String, Object> json =
MAPPER.readValue(resultFiles.get(0).getContent(), Map.class);
+ Map<String, Object> json =
MAPPER.readValue(resultFiles.getFirst().getContent(), Map.class);
assertEquals(MY_DB, json.get(DATABASE_KEY));
assertEquals(MY_TABLE, json.get("table_name"));
}
@@ -767,7 +769,7 @@ public class CaptureChangeMySQLTest {
// Five events total, 2 max per flow file, so 3 flow files
assertEquals(3, resultFiles.size());
- List<Map<String, Object>> json =
MAPPER.readValue(resultFiles.get(0).toByteArray(), List.class);
+ List<Map<String, Object>> json =
MAPPER.readValue(resultFiles.getFirst().toByteArray(), List.class);
assertEquals(2, json.size());
// BEGIN, INSERT, COMMIT (verifies that one of the INSERTs was skipped)
assertEquals(BEGIN_SQL_KEYWORD_LOWERCASE, json.get(0).get(TYPE_KEY));
@@ -781,7 +783,7 @@ public class CaptureChangeMySQLTest {
json = MAPPER.readValue(resultFiles.get(2).toByteArray(), List.class);
// One event left
assertEquals(1, json.size());
- assertEquals(COMMIT_SQL_KEYWORD_LOWERCASE, json.get(0).get(TYPE_KEY));
+ assertEquals(COMMIT_SQL_KEYWORD_LOWERCASE,
json.getFirst().get(TYPE_KEY));
}
@SuppressWarnings("unchecked")
@@ -867,7 +869,7 @@ public class CaptureChangeMySQLTest {
List<MockFlowFile> resultFiles =
testRunner.getFlowFilesForRelationship(CaptureChangeMySQL.REL_SUCCESS);
// Five events total, 3 max per flow file, so 2 flow files
assertEquals(2, resultFiles.size());
- List<Map<String, Object>> json =
MAPPER.readValue(resultFiles.get(0).toByteArray(), List.class);
+ List<Map<String, Object>> json =
MAPPER.readValue(resultFiles.getFirst().toByteArray(), List.class);
assertEquals(3, json.size());
// BEGIN, INSERT, COMMIT (verifies that one of the INSERTs was skipped)
assertEquals(BEGIN_SQL_KEYWORD_LOWERCASE, json.get(0).get(TYPE_KEY));
@@ -1230,7 +1232,7 @@ public class CaptureChangeMySQLTest {
assertEquals(2, resultFiles.size());
assertEquals(EventUtils.buildGtid(GTID_SOURCE_ID, "2-3"),
- resultFiles.get(resultFiles.size() -
1).getAttribute(BinlogEventInfo.BINLOG_GTIDSET_KEY));
+
resultFiles.getLast().getAttribute(BinlogEventInfo.BINLOG_GTIDSET_KEY));
}
@Test
@@ -1267,7 +1269,7 @@ public class CaptureChangeMySQLTest {
assertEquals(2, resultFiles.size());
assertEquals(EventUtils.buildGtid(GTID_SOURCE_ID, "1-1", "3-3"),
- resultFiles.get(resultFiles.size() -
1).getAttribute(BinlogEventInfo.BINLOG_GTIDSET_KEY));
+
resultFiles.getLast().getAttribute(BinlogEventInfo.BINLOG_GTIDSET_KEY));
}
@Test
@@ -1294,6 +1296,40 @@ public class CaptureChangeMySQLTest {
assertEquals("alter table", processor.normalizeQuery(" /* This is a \n
multiline comment test */ alter table"));
}
+ @Test
+ void testMigration() {
+ final Map<String, String> expectedRenamed = Map.ofEntries(
+ Map.entry("capture-change-mysql-db-name-pattern",
CaptureChangeMySQL.DATABASE_NAME_PATTERN.getName()),
+ Map.entry("capture-change-mysql-name-pattern",
CaptureChangeMySQL.TABLE_NAME_PATTERN.getName()),
+ Map.entry("capture-change-mysql-max-wait-time",
CaptureChangeMySQL.CONNECT_TIMEOUT.getName()),
+ Map.entry("capture-change-mysql-hosts",
CaptureChangeMySQL.HOSTS.getName()),
+ Map.entry("capture-change-mysql-driver-class",
CaptureChangeMySQL.DRIVER_NAME.getName()),
+ Map.entry("capture-change-mysql-driver-locations",
CaptureChangeMySQL.DRIVER_LOCATION.getName()),
+ Map.entry("MySQL Driver Location(s)",
CaptureChangeMySQL.DRIVER_LOCATION.getName()),
+ Map.entry("capture-change-mysql-username",
CaptureChangeMySQL.USERNAME.getName()),
+ Map.entry("capture-change-mysql-password",
CaptureChangeMySQL.PASSWORD.getName()),
+ Map.entry("events-per-flowfile-strategy",
CaptureChangeMySQL.EVENTS_PER_FLOWFILE_STRATEGY.getName()),
+ Map.entry("number-of-events-per-flowfile",
CaptureChangeMySQL.NUMBER_OF_EVENTS_PER_FLOWFILE.getName()),
+ Map.entry("capture-change-mysql-server-id",
CaptureChangeMySQL.SERVER_ID.getName()),
+ Map.entry("capture-change-mysql-retrieve-all-records",
CaptureChangeMySQL.RETRIEVE_ALL_RECORDS.getName()),
+ Map.entry("capture-change-mysql-include-begin-commit",
CaptureChangeMySQL.INCLUDE_BEGIN_COMMIT.getName()),
+ Map.entry("capture-change-mysql-include-ddl-events",
CaptureChangeMySQL.INCLUDE_DDL_EVENTS.getName()),
+ Map.entry("capture-change-mysql-init-seq-id",
CaptureChangeMySQL.INIT_SEQUENCE_ID.getName()),
+ Map.entry("capture-change-mysql-init-binlog-filename",
CaptureChangeMySQL.INIT_BINLOG_FILENAME.getName()),
+ Map.entry("capture-change-mysql-init-binlog-position",
CaptureChangeMySQL.INIT_BINLOG_POSITION.getName()),
+ Map.entry("capture-change-mysql-use-gtid",
CaptureChangeMySQL.USE_BINLOG_GTID.getName()),
+ Map.entry("capture-change-mysql-init-gtid",
CaptureChangeMySQL.INIT_BINLOG_GTID.getName())
+ );
+
+ final PropertyMigrationResult propertyMigrationResult =
testRunner.migrateProperties();
+ assertEquals(expectedRenamed,
propertyMigrationResult.getPropertiesRenamed());
+
+ final Set<String> expectedRemoved =
Set.of("capture-change-mysql-state-update-interval",
+ "capture-change-mysql-dist-map-cache-client",
+ "Distributed Map Cache Client - unused");
+ assertEquals(expectedRemoved,
propertyMigrationResult.getPropertiesRemoved());
+ }
+
/********************************
* Mock and helper classes below
********************************/
@@ -1314,12 +1350,8 @@ public class CaptureChangeMySQLTest {
@Override
protected TableInfo loadTableInfo(TableInfoCacheKey key) {
- TableInfo tableInfo = cache.get(key);
- if (tableInfo == null) {
- tableInfo = new TableInfo(key.getDatabaseName(),
key.getTableName(), key.getTableId(),
- Collections.singletonList(new ColumnDefinition((byte)
-4, "string1")));
- cache.put(key, tableInfo);
- }
+ TableInfo tableInfo = cache.computeIfAbsent(key, k -> new
TableInfo(k.getDatabaseName(), k.getTableName(), k.getTableId(),
+ Collections.singletonList(new ColumnDefinition((byte) -4,
"string1"))));
return tableInfo;
}
diff --git
a/nifi-extension-bundles/nifi-cipher-bundle/nifi-cipher-processors/src/test/java/org/apache/nifi/processors/cipher/VerifyContentMACTest.java
b/nifi-extension-bundles/nifi-cipher-bundle/nifi-cipher-processors/src/test/java/org/apache/nifi/processors/cipher/VerifyContentMACTest.java
index d584fd33b7..1d6e565be4 100644
---
a/nifi-extension-bundles/nifi-cipher-bundle/nifi-cipher-processors/src/test/java/org/apache/nifi/processors/cipher/VerifyContentMACTest.java
+++
b/nifi-extension-bundles/nifi-cipher-bundle/nifi-cipher-processors/src/test/java/org/apache/nifi/processors/cipher/VerifyContentMACTest.java
@@ -18,6 +18,7 @@
package org.apache.nifi.processors.cipher;
import org.apache.nifi.processors.cipher.VerifyContentMAC.Encoding;
+import org.apache.nifi.util.PropertyMigrationResult;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.jupiter.api.BeforeEach;
@@ -38,6 +39,7 @@ import static
org.apache.nifi.processors.cipher.VerifyContentMAC.MAC_ALGORITHM_A
import static
org.apache.nifi.processors.cipher.VerifyContentMAC.MAC_CALCULATED_ATTRIBUTE;
import static
org.apache.nifi.processors.cipher.VerifyContentMAC.MAC_ENCODING_ATTRIBUTE;
import static org.apache.nifi.processors.cipher.VerifyContentMAC.SUCCESS;
+import static org.junit.jupiter.api.Assertions.assertEquals;
class VerifyContentMACTest {
@@ -176,4 +178,18 @@ class VerifyContentMACTest {
runner.assertAllFlowFilesTransferred(FAILURE);
}
+
+ @Test
+ void testMigration() {
+ final Map<String, String> expected = Map.ofEntries(
+ Map.entry("mac-algorithm",
VerifyContentMAC.MAC_ALGORITHM.getName()),
+ Map.entry("message-authentication-code-encoding",
VerifyContentMAC.MAC_ENCODING.getName()),
+ Map.entry("message-authentication-code",
VerifyContentMAC.MAC.getName()),
+ Map.entry("secret-key-encoding",
VerifyContentMAC.SECRET_KEY_ENCODING.getName()),
+ Map.entry("secret-key", VerifyContentMAC.SECRET_KEY.getName())
+ );
+
+ final PropertyMigrationResult propertyMigrationResult =
runner.migrateProperties();
+ assertEquals(expected, propertyMigrationResult.getPropertiesRenamed());
+ }
}
\ No newline at end of file
diff --git
a/nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/test/java/org/apache/nifi/confluent/schemaregistry/ConfluentSchemaRegistryTest.java
b/nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/test/java/org/apache/nifi/confluent/schemaregistry/ConfluentSchemaRegistryTest.java
index 2abfa63277..f4aacc6d7d 100644
---
a/nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/test/java/org/apache/nifi/confluent/schemaregistry/ConfluentSchemaRegistryTest.java
+++
b/nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/test/java/org/apache/nifi/confluent/schemaregistry/ConfluentSchemaRegistryTest.java
@@ -17,13 +17,18 @@
package org.apache.nifi.confluent.schemaregistry;
import org.apache.nifi.confluent.schemaregistry.client.AuthenticationType;
-import org.apache.nifi.processor.Processor;
import org.apache.nifi.reporting.InitializationException;
+import org.apache.nifi.util.MockPropertyConfiguration;
+import org.apache.nifi.util.NoOpProcessor;
+import org.apache.nifi.util.PropertyMigrationResult;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
+
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
class ConfluentSchemaRegistryTest {
@@ -36,8 +41,7 @@ class ConfluentSchemaRegistryTest {
@BeforeEach
public void setUp() throws InitializationException {
registry = new ConfluentSchemaRegistry();
- final Processor processor = Mockito.mock(Processor.class);
- runner = TestRunners.newTestRunner(processor);
+ runner = TestRunners.newTestRunner(NoOpProcessor.class);
runner.addControllerService(SERVICE_ID, registry);
}
@@ -101,4 +105,28 @@ class ConfluentSchemaRegistryTest {
runner.setProperty(registry, "not.valid.subject", "NotValid");
runner.assertNotValid(registry);
}
+
+ @Test
+ void testMigration() {
+ final Map<String, String> propertyValues = Map.of();
+ final MockPropertyConfiguration configuration = new
MockPropertyConfiguration(propertyValues);
+ final ConfluentSchemaRegistry confluentSchemaRegistry = new
ConfluentSchemaRegistry();
+ confluentSchemaRegistry.migrateProperties(configuration);
+
+ Map<String, String> expected = Map.ofEntries(
+ Map.entry("url",
ConfluentSchemaRegistry.SCHEMA_REGISTRY_URLS.getName()),
+ Map.entry("ssl-context",
ConfluentSchemaRegistry.SSL_CONTEXT.getName()),
+ Map.entry("cache-size",
ConfluentSchemaRegistry.CACHE_SIZE.getName()),
+ Map.entry("cache-expiration",
ConfluentSchemaRegistry.CACHE_EXPIRATION.getName()),
+ Map.entry("timeout",
ConfluentSchemaRegistry.TIMEOUT.getName()),
+ Map.entry("authentication-type",
ConfluentSchemaRegistry.AUTHENTICATION_TYPE.getName()),
+ Map.entry("username",
ConfluentSchemaRegistry.USERNAME.getName()),
+ Map.entry("password",
ConfluentSchemaRegistry.PASSWORD.getName())
+ );
+
+ final PropertyMigrationResult result =
configuration.toPropertyMigrationResult();
+ final Map<String, String> propertiesRenamed =
result.getPropertiesRenamed();
+
+ assertEquals(expected, propertiesRenamed);
+ }
}
diff --git
a/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/test/java/org/apache/nifi/processors/dropbox/TestDropboxProcessorMigration.java
b/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/test/java/org/apache/nifi/processors/dropbox/TestDropboxProcessorMigration.java
new file mode 100644
index 0000000000..4732d72b95
--- /dev/null
+++
b/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/test/java/org/apache/nifi/processors/dropbox/TestDropboxProcessorMigration.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.processors.dropbox;
+
+import org.apache.nifi.processor.util.list.AbstractListProcessor;
+import org.apache.nifi.processor.util.list.ListedEntityTracker;
+import org.apache.nifi.proxy.ProxyConfigurationService;
+import org.apache.nifi.util.PropertyMigrationResult;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class TestDropboxProcessorMigration {
+
+ @Test
+ void testFetchDropboxMigration() {
+ TestRunner runner = TestRunners.newTestRunner(FetchDropbox.class);
+ final Map<String, String> expected = Map.ofEntries(
+ Map.entry(DropboxTrait.OLD_CREDENTIAL_SERVICE_PROPERTY_NAME,
DropboxTrait.CREDENTIAL_SERVICE.getName()),
+ Map.entry("file", FetchDropbox.FILE.getName()),
+
Map.entry(ProxyConfigurationService.OBSOLETE_PROXY_CONFIGURATION_SERVICE,
ProxyConfigurationService.PROXY_CONFIGURATION_SERVICE.getName())
+ );
+
+ final PropertyMigrationResult propertyMigrationResult =
runner.migrateProperties();
+ assertEquals(expected, propertyMigrationResult.getPropertiesRenamed());
+ }
+
+ @Test
+ void testPutDropboxMigration() {
+ TestRunner runner = TestRunners.newTestRunner(PutDropbox.class);
+ final Map<String, String> expected = Map.ofEntries(
+ Map.entry(DropboxTrait.OLD_CREDENTIAL_SERVICE_PROPERTY_NAME,
DropboxTrait.CREDENTIAL_SERVICE.getName()),
+ Map.entry("folder", PutDropbox.FOLDER.getName()),
+ Map.entry("file-name", PutDropbox.FILE_NAME.getName()),
+ Map.entry("conflict-resolution-strategy",
PutDropbox.CONFLICT_RESOLUTION.getName()),
+ Map.entry("chunked-upload-size",
PutDropbox.CHUNKED_UPLOAD_SIZE.getName()),
+ Map.entry("chunked-upload-threshold",
PutDropbox.CHUNKED_UPLOAD_THRESHOLD.getName()),
+
Map.entry(ProxyConfigurationService.OBSOLETE_PROXY_CONFIGURATION_SERVICE,
ProxyConfigurationService.PROXY_CONFIGURATION_SERVICE.getName())
+ );
+
+ final PropertyMigrationResult propertyMigrationResult =
runner.migrateProperties();
+ assertEquals(expected, propertyMigrationResult.getPropertiesRenamed());
+ }
+
+ @Test
+ void testListDropboxMigration() {
+ TestRunner runner = TestRunners.newTestRunner(ListDropbox.class);
+ final Map<String, String> expected = Map.ofEntries(
+ Map.entry("target-system-timestamp-precision",
AbstractListProcessor.TARGET_SYSTEM_TIMESTAMP_PRECISION.getName()),
+ Map.entry("listing-strategy",
AbstractListProcessor.LISTING_STRATEGY.getName()),
+ Map.entry("record-writer",
AbstractListProcessor.RECORD_WRITER.getName()),
+ Map.entry(DropboxTrait.OLD_CREDENTIAL_SERVICE_PROPERTY_NAME,
DropboxTrait.CREDENTIAL_SERVICE.getName()),
+ Map.entry("folder", ListDropbox.FOLDER.getName()),
+ Map.entry("recursive-search",
ListDropbox.RECURSIVE_SEARCH.getName()),
+ Map.entry("min-age", ListDropbox.MIN_AGE.getName()),
+
Map.entry(ListedEntityTracker.OLD_TRACKING_STATE_CACHE_PROPERTY_NAME,
ListedEntityTracker.TRACKING_STATE_CACHE.getName()),
+
Map.entry(ListedEntityTracker.OLD_TRACKING_TIME_WINDOW_PROPERTY_NAME,
ListedEntityTracker.TRACKING_TIME_WINDOW.getName()),
+
Map.entry(ListedEntityTracker.OLD_INITIAL_LISTING_TARGET_PROPERTY_NAME,
ListedEntityTracker.INITIAL_LISTING_TARGET.getName()),
+
Map.entry(ProxyConfigurationService.OBSOLETE_PROXY_CONFIGURATION_SERVICE,
ProxyConfigurationService.PROXY_CONFIGURATION_SERVICE.getName())
+ );
+
+ final PropertyMigrationResult propertyMigrationResult =
runner.migrateProperties();
+ assertEquals(expected, propertyMigrationResult.getPropertiesRenamed());
+
+ final Set<String> expectedRemoved = Set.of("Distributed Cache
Service");
+ assertEquals(expectedRemoved,
propertyMigrationResult.getPropertiesRemoved());
+ }
+}
diff --git
a/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-services/src/test/java/org/apache/nifi/services/dropbox/StandardDropboxCredentialServiceTest.java
b/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-services/src/test/java/org/apache/nifi/services/dropbox/StandardDropboxCredentialServiceTest.java
new file mode 100644
index 0000000000..91af7814d8
--- /dev/null
+++
b/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-services/src/test/java/org/apache/nifi/services/dropbox/StandardDropboxCredentialServiceTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.services.dropbox;
+
+import org.apache.nifi.util.MockPropertyConfiguration;
+import org.apache.nifi.util.PropertyMigrationResult;
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class StandardDropboxCredentialServiceTest {
+ @Test
+ void testMigration() {
+ final Map<String, String> propertyValues = Map.of(
+ StandardDropboxCredentialService.ACCESS_TOKEN.getName(),
"someAccessToken",
+ StandardDropboxCredentialService.APP_KEY.getName(),
"someAppKey",
+ StandardDropboxCredentialService.APP_SECRET.getName(),
"someAppSecret",
+ StandardDropboxCredentialService.REFRESH_TOKEN.getName(),
"someRefreshToken"
+ );
+
+ final MockPropertyConfiguration configuration = new
MockPropertyConfiguration(propertyValues);
+ final StandardDropboxCredentialService
standardDropboxCredentialService = new StandardDropboxCredentialService();
+ standardDropboxCredentialService.migrateProperties(configuration);
+
+ Map<String, String> expected = Map.ofEntries(
+ Map.entry("app-key",
StandardDropboxCredentialService.APP_KEY.getName()),
+ Map.entry("app-secret",
StandardDropboxCredentialService.APP_SECRET.getName()),
+ Map.entry("access-token",
StandardDropboxCredentialService.ACCESS_TOKEN.getName()),
+ Map.entry("refresh-token",
StandardDropboxCredentialService.REFRESH_TOKEN.getName())
+ );
+
+ final PropertyMigrationResult result =
configuration.toPropertyMigrationResult();
+ final Map<String, String> propertiesRenamed =
result.getPropertiesRenamed();
+
+ assertEquals(expected, propertiesRenamed);
+ }
+}