This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 471c3ad692e1 Fix S5783: extract setup code from assertThrows lambdas 
(#24369)
471c3ad692e1 is described below

commit 471c3ad692e154238bb8ecd814f65bf160a1d18a
Author: Guillaume Nodet <[email protected]>
AuthorDate: Thu Jul 2 12:01:27 2026 +0200

    Fix S5783: extract setup code from assertThrows lambdas (#24369)
    
    Only the single call expected to throw remains inside assertThrows.
    
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 ...PlatformHttpRestOpenApiConsumerRestDslTest.java | 18 +++++------
 .../vertx/PlatformHttpRestOpenApiConsumerTest.java | 20 ++++++------
 .../http/PlatformHttpOAuthProfileTest.java         | 36 ++++++++++------------
 3 files changed, 36 insertions(+), 38 deletions(-)

diff --git 
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslTest.java
 
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslTest.java
index 6af6ad31f5af..bde7c1019670 100644
--- 
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslTest.java
+++ 
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslTest.java
@@ -133,17 +133,17 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
         final CamelContext context = 
VertxPlatformHttpEngineTest.createCamelContext();
 
         try {
-            assertThrows(Exception.class, () -> {
-                context.addRoutes(new RouteBuilder() {
-                    @Override
-                    public void configure() {
-                        rest().openApi("openapi-v3.json");
+            context.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() {
+                    rest().openApi("openapi-v3.json");
 
-                        from("direct:getPetById")
-                                .setBody().constant("{\"pet\": \"tony the 
tiger\"}");
-                    }
-                });
+                    from("direct:getPetById")
+                            .setBody().constant("{\"pet\": \"tony the 
tiger\"}");
+                }
+            });
 
+            assertThrows(Exception.class, () -> {
                 VertxPlatformHttpEngineTest.startCamelContext(context);
             }, "OpenAPI specification has 18 unmapped operations to 
corresponding routes");
         } finally {
diff --git 
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerTest.java
 
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerTest.java
index d4fda8c408ec..fb7cca2564d5 100644
--- 
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerTest.java
+++ 
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerTest.java
@@ -135,18 +135,18 @@ public class PlatformHttpRestOpenApiConsumerTest {
         final CamelContext context = 
VertxPlatformHttpEngineTest.createCamelContext();
 
         try {
-            assertThrows(Exception.class, () -> {
-                context.addRoutes(new RouteBuilder() {
-                    @Override
-                    public void configure() {
-                        
from("rest-openapi:classpath:openapi-v3.json?missingOperation=fail")
-                                .log("dummy");
+            context.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() {
+                    
from("rest-openapi:classpath:openapi-v3.json?missingOperation=fail")
+                            .log("dummy");
 
-                        from("direct:getPetById")
-                                .setBody().constant("{\"pet\": \"tony the 
tiger\"}");
-                    }
-                });
+                    from("direct:getPetById")
+                            .setBody().constant("{\"pet\": \"tony the 
tiger\"}");
+                }
+            });
 
+            assertThrows(Exception.class, () -> {
                 VertxPlatformHttpEngineTest.startCamelContext(context);
             }, "OpenAPI specification has 18 unmapped operations to 
corresponding routes");
         } finally {
diff --git 
a/components/camel-platform-http/src/test/java/org/apache/camel/component/platform/http/PlatformHttpOAuthProfileTest.java
 
b/components/camel-platform-http/src/test/java/org/apache/camel/component/platform/http/PlatformHttpOAuthProfileTest.java
index f0d619c3f31a..d30e13c4c989 100644
--- 
a/components/camel-platform-http/src/test/java/org/apache/camel/component/platform/http/PlatformHttpOAuthProfileTest.java
+++ 
b/components/camel-platform-http/src/test/java/org/apache/camel/component/platform/http/PlatformHttpOAuthProfileTest.java
@@ -181,29 +181,27 @@ class PlatformHttpOAuthProfileTest {
     }
 
     @Test
-    void oauthProfileSpecificWrongTypeValidationFactoryBeanFailsStartup() {
+    void oauthProfileSpecificWrongTypeValidationFactoryBeanFailsStartup() 
throws Exception {
         CapturingEngine engine = new CapturingEngine();
 
-        assertThrows(Exception.class, () -> {
-            try (DefaultCamelContext context = new DefaultCamelContext()) {
-                context.getRegistry().bind("profileFactory", "not a token 
validation factory");
-                context.getPropertiesComponent().addInitialProperty(
-                        "camel.oauth.myprofile.validation-factory", 
"#bean:profileFactory");
+        try (DefaultCamelContext context = new DefaultCamelContext()) {
+            context.getRegistry().bind("profileFactory", "not a token 
validation factory");
+            context.getPropertiesComponent().addInitialProperty(
+                    "camel.oauth.myprofile.validation-factory", 
"#bean:profileFactory");
 
-                PlatformHttpComponent component = new PlatformHttpComponent();
-                component.setEngine(engine);
-                context.addComponent("platform-http", component);
-                context.addRoutes(new RouteBuilder() {
-                    @Override
-                    public void configure() {
-                        from("platform-http:/secure?oauthProfile=myprofile")
-                                .setBody().constant("secured");
-                    }
-                });
+            PlatformHttpComponent component = new PlatformHttpComponent();
+            component.setEngine(engine);
+            context.addComponent("platform-http", component);
+            context.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() {
+                    from("platform-http:/secure?oauthProfile=myprofile")
+                            .setBody().constant("secured");
+                }
+            });
 
-                context.start();
-            }
-        });
+            assertThrows(Exception.class, () -> context.start());
+        }
     }
 
     @Test

Reply via email to