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 d51f12b45e9 NIFI-16484 Replaced assertTrue and instanceof checks with
assertInstanceOf (#11830)
d51f12b45e9 is described below
commit d51f12b45e98015db34c571fe92425be0263e0e0
Author: dan-s1 <[email protected]>
AuthorDate: Thu Oct 22 17:01:35 2026 -0400
NIFI-16484 Replaced assertTrue and instanceof checks with assertInstanceOf
(#11830)
Signed-off-by: David Handermann <[email protected]>
---
.../connector/TestEligibilityConnectorMigrationContext.java | 3 ++-
.../nifi/components/connector/TestStandardConnectorRepository.java | 5 +++--
.../connector/TestStandardFrameworkConnectorMigrationContext.java | 4 ++--
.../java/org/apache/nifi/controller/TestStandardFlowService.java | 3 ++-
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestEligibilityConnectorMigrationContext.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestEligibilityConnectorMigrationContext.java
index f92da9fda8f..f887af3896f 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestEligibilityConnectorMigrationContext.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestEligibilityConnectorMigrationContext.java
@@ -23,6 +23,7 @@ import org.apache.nifi.flow.VersionedExternalFlow;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -58,7 +59,7 @@ public class TestEligibilityConnectorMigrationContext {
// The underlying StandardFrameworkConnectorMigrationContext wraps the
active flow context in a
// MigrationFlowContext so any updateFlow() call from the eligibility
path throws as well; the eligibility
// wrapper just propagates that read-only handle.
- assertTrue(eligibilityContext.getActiveFlowContext() instanceof
MigrationFlowContext,
+ assertInstanceOf(MigrationFlowContext.class,
eligibilityContext.getActiveFlowContext(),
"Eligibility context must propagate the read-only
MigrationFlowContext returned by the underlying migration context");
assertSame(sourceAssetManager,
eligibilityContext.getSourceAssetManager());
assertSame(connectorRepository,
eligibilityContext.getConnectorRepository());
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestStandardConnectorRepository.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestStandardConnectorRepository.java
index a827f0e13f3..0a3939b9b85 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestStandardConnectorRepository.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestStandardConnectorRepository.java
@@ -62,6 +62,7 @@ import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -514,7 +515,7 @@ public class TestStandardConnectorRepository {
final ConnectorConfigurationProviderException exception = assertThrows(
ConnectorConfigurationProviderException.class, () ->
repository.addConnector(connector));
- assertTrue(exception.getCause() instanceof FlowUpdateException);
+ assertInstanceOf(FlowUpdateException.class, exception.getCause());
assertNull(repository.getConnector("connector-1",
ConnectorSyncMode.LOCAL_ONLY));
verify(connector, never()).setName(anyString());
}
@@ -1369,7 +1370,7 @@ public class TestStandardConnectorRepository {
final ConnectorConfigurationProviderException exception = assertThrows(
ConnectorConfigurationProviderException.class, () ->
repository.applyUpdate(connector, updateContext));
- assertTrue(exception.getCause() instanceof FlowUpdateException);
+ assertInstanceOf(FlowUpdateException.class, exception.getCause());
verify(provider).syncAssets("connector-1");
verify(connector, never()).setName(anyString());
verify(connector, never()).transitionStateForUpdating();
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestStandardFrameworkConnectorMigrationContext.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestStandardFrameworkConnectorMigrationContext.java
index 43a20c79403..92fe601b450 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestStandardFrameworkConnectorMigrationContext.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestStandardFrameworkConnectorMigrationContext.java
@@ -39,6 +39,7 @@ import java.util.Optional;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -344,8 +345,7 @@ public class TestStandardFrameworkConnectorMigrationContext
{
final FrameworkFlowContext active = context.getActiveFlowContext();
assertNotNull(active);
- assertTrue(active instanceof MigrationFlowContext,
- "getActiveFlowContext() must return the read-only
MigrationFlowContext wrapper");
+ assertInstanceOf(MigrationFlowContext.class, active,
"getActiveFlowContext() must return the read-only MigrationFlowContext
wrapper");
}
private StandardFrameworkConnectorMigrationContext createContext(final
boolean localMigration) {
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestStandardFlowService.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestStandardFlowService.java
index ad4fbab9652..a2ca29fecec 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestStandardFlowService.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestStandardFlowService.java
@@ -67,6 +67,7 @@ import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -441,7 +442,7 @@ public class TestStandardFlowService {
final StandardFlowService.GracefulOffloadResult result =
context.flowService.awaitGracefulProcessorStop(context.rootGroup, List.of());
assertEquals(StandardFlowService.GracefulOffloadOutcome.EXCEPTIONAL,
result.outcome());
- assertTrue(result.cause() instanceof CancellationException);
+ assertInstanceOf(CancellationException.class, result.cause());
}
@Test