This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch fix/CAMEL-24345-test in repository https://gitbox.apache.org/repos/asf/camel.git
commit e62c08b80ff78aa63b24891170dd091dcb211bab Author: Claus Ibsen <[email protected]> AuthorDate: Thu Aug 6 17:30:03 2026 +0200 CAMEL-24345: Fix GoogleVertexAIProducerOptionsTest to not require Google credentials Construct the configuration and endpoint directly instead of resolving through CamelContext, which triggers doStart() and credential lookup. The test only verifies buildConfig() and determineStreamOutputMode() behavior, not actual Google Cloud connectivity. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../GoogleVertexAIProducerOptionsTest.java | 38 +++++++++++++--------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/components/camel-google/camel-google-vertexai/src/test/java/org/apache/camel/component/google/vertexai/GoogleVertexAIProducerOptionsTest.java b/components/camel-google/camel-google-vertexai/src/test/java/org/apache/camel/component/google/vertexai/GoogleVertexAIProducerOptionsTest.java index e3e7c74de94f..82b2ed1ec37d 100644 --- a/components/camel-google/camel-google-vertexai/src/test/java/org/apache/camel/component/google/vertexai/GoogleVertexAIProducerOptionsTest.java +++ b/components/camel-google/camel-google-vertexai/src/test/java/org/apache/camel/component/google/vertexai/GoogleVertexAIProducerOptionsTest.java @@ -26,12 +26,11 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; /** - * Verifies that the producer applies the options that describe the shape of the request and of the response. + * Verifies that the producer applies the options that describe the shape of the request and of the response. Uses + * direct object construction to avoid starting the endpoint (which requires Google Cloud credentials). */ class GoogleVertexAIProducerOptionsTest { - private static final String BASE = "google-vertexai:my-project:us-central1:gemini-2.0-flash"; - private DefaultCamelContext context; @AfterEach @@ -41,30 +40,36 @@ class GoogleVertexAIProducerOptionsTest { } } - private GoogleVertexAIProducer producer(String query) throws Exception { + private GoogleVertexAIProducer producer(GoogleVertexAIConfiguration config) { context = new DefaultCamelContext(); - context.start(); - GoogleVertexAIEndpoint endpoint = context.getEndpoint(BASE + query, GoogleVertexAIEndpoint.class); + GoogleVertexAIComponent component = new GoogleVertexAIComponent(context); + GoogleVertexAIEndpoint endpoint + = new GoogleVertexAIEndpoint("google-vertexai:my-project:us-central1:gemini-2.0-flash", component, config); return new GoogleVertexAIProducer(endpoint); } @Test - void jsonModeAsksTheModelForJson() throws Exception { - GenerateContentConfig config = producer("?jsonMode=true").buildConfig(new DefaultExchange(context)); + void jsonModeAsksTheModelForJson() { + GoogleVertexAIConfiguration config = new GoogleVertexAIConfiguration(); + config.setJsonMode(true); + GenerateContentConfig result = producer(config).buildConfig(new DefaultExchange(context)); - assertThat(config.responseMimeType()).contains("application/json"); + assertThat(result.responseMimeType()).contains("application/json"); } @Test - void jsonModeIsOffByDefault() throws Exception { - GenerateContentConfig config = producer("").buildConfig(new DefaultExchange(context)); + void jsonModeIsOffByDefault() { + GoogleVertexAIConfiguration config = new GoogleVertexAIConfiguration(); + GenerateContentConfig result = producer(config).buildConfig(new DefaultExchange(context)); - assertThat(config.responseMimeType()).isEmpty(); + assertThat(result.responseMimeType()).isEmpty(); } @Test - void theStreamOutputModeComesFromTheConfigurationOrTheHeader() throws Exception { - GoogleVertexAIProducer producer = producer("?streamOutputMode=chunks"); + void theStreamOutputModeComesFromTheConfigurationOrTheHeader() { + GoogleVertexAIConfiguration config = new GoogleVertexAIConfiguration(); + config.setStreamOutputMode("chunks"); + GoogleVertexAIProducer producer = producer(config); Exchange exchange = new DefaultExchange(context); assertThat(producer.determineStreamOutputMode(exchange)).isEqualTo("chunks"); @@ -75,7 +80,8 @@ class GoogleVertexAIProducerOptionsTest { } @Test - void theStreamOutputModeDefaultsToComplete() throws Exception { - assertThat(producer("").determineStreamOutputMode(new DefaultExchange(context))).isEqualTo("complete"); + void theStreamOutputModeDefaultsToComplete() { + GoogleVertexAIConfiguration config = new GoogleVertexAIConfiguration(); + assertThat(producer(config).determineStreamOutputMode(new DefaultExchange(context))).isEqualTo("complete"); } }
