This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit a7109a345b2657cbad3fb0289e1f0d83e897a375 Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Sat Jan 24 19:47:53 2026 +0000 CAMEL-21196: modernize exception-based assertions in camel-workday Replace try-catch-fail patterns with assertThrows in: - WorkdayCommonAPIProducerTest.java (2 occurrences) - WorkdayReportProducerTest.java (1 occurrence) --- .../apache/camel/WorkdayCommonAPIProducerTest.java | 27 +++++----------------- .../apache/camel/WorkdayReportProducerTest.java | 15 ++++-------- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/components/camel-workday/src/test/java/org/apache/camel/WorkdayCommonAPIProducerTest.java b/components/camel-workday/src/test/java/org/apache/camel/WorkdayCommonAPIProducerTest.java index 6c32f8595d8e..acc33c4b22c4 100644 --- a/components/camel-workday/src/test/java/org/apache/camel/WorkdayCommonAPIProducerTest.java +++ b/components/camel-workday/src/test/java/org/apache/camel/WorkdayCommonAPIProducerTest.java @@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.fail; public class WorkdayCommonAPIProducerTest extends CamelTestSupport { @@ -56,21 +55,14 @@ public class WorkdayCommonAPIProducerTest extends CamelTestSupport { public void createProducerNoHostConfiguration() { WorkdayComponent workdayComponent = context.getComponent("workday", WorkdayComponent.class); - try { - + Exception exception = assertThrows(IllegalArgumentException.class, () -> { WorkdayEndpoint workdayEndpoint = (WorkdayEndpoint) workdayComponent .createEndpoint( "workday:commonAPI:/workers?" + "tenant=camel" + "&clientId=f7014d38-99d2-4969-b740-b5b62db6b46a" + "&clientSecret=7dbaf280-3cea-11ea-b77f-2e728ce88125" + "&tokenRefresh=88689ab63cda" + "&format=json"); - } catch (Exception exception) { - - assertEquals(exception.getClass(), IllegalArgumentException.class); - assertEquals("Host must be specified", exception.getMessage()); - return; - } - - fail("Required parameters validation failed."); + }); + assertEquals("Host must be specified", exception.getMessage()); } @Test @@ -85,17 +77,10 @@ public class WorkdayCommonAPIProducerTest extends CamelTestSupport { WorkdayCommonAPIProducer workdayProducer = new WorkdayCommonAPIProducer(workdayEndpoint); - try { - + Exception exception = assertThrows(MalformedURLException.class, () -> { String workdayUri = workdayProducer.prepareUri(workdayEndpoint.getWorkdayConfiguration()); - } catch (Exception exception) { - - assertEquals(exception.getClass(), MalformedURLException.class); - assertEquals("An invalid Workday Common endpoint: '/worker' was provided.", exception.getMessage()); - return; - } - - fail("Required parameters validation failed."); + }); + assertEquals("An invalid Workday Common endpoint: '/worker' was provided.", exception.getMessage()); } @Test diff --git a/components/camel-workday/src/test/java/org/apache/camel/WorkdayReportProducerTest.java b/components/camel-workday/src/test/java/org/apache/camel/WorkdayReportProducerTest.java index 9f11ab4cc0de..0e8a62e384b2 100644 --- a/components/camel-workday/src/test/java/org/apache/camel/WorkdayReportProducerTest.java +++ b/components/camel-workday/src/test/java/org/apache/camel/WorkdayReportProducerTest.java @@ -24,7 +24,7 @@ import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; public class WorkdayReportProducerTest extends CamelTestSupport { @@ -53,21 +53,14 @@ public class WorkdayReportProducerTest extends CamelTestSupport { public void createProducerNoHostConfiguration() { WorkdayComponent workdayComponent = context.getComponent("workday", WorkdayComponent.class); - try { - + Exception exception = assertThrows(IllegalArgumentException.class, () -> { WorkdayEndpoint workdayEndpoint = (WorkdayEndpoint) workdayComponent .createEndpoint("workday:report:/ISU_Camel/Custom_Report_Employees?" + "tenant=camel" + "&clientId=f7014d38-99d2-4969-b740-b5b62db6b46a" + "&clientSecret=7dbaf280-3cea-11ea-b77f-2e728ce88125" + "&tokenRefresh=88689ab63cda" + "&format=json"); - } catch (Exception exception) { - - assertEquals(IllegalArgumentException.class, exception.getClass()); - assertEquals("Host must be specified", exception.getMessage()); - return; - } - - fail("Required parameters validation failed."); + }); + assertEquals("Host must be specified", exception.getMessage()); } @Test
