This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 c1a313f9f015 CAMEL-24345: Fix GoogleVertexAIProducerOptionsTest to not
require Google credentials (#25391)
c1a313f9f015 is described below
commit c1a313f9f015aebd9797a29704432643e7f5eec5
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Aug 6 19:13:52 2026 +0200
CAMEL-24345: Fix GoogleVertexAIProducerOptionsTest to not require Google
credentials (#25391)
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.
Signed-off-by: Claus Ibsen <[email protected]>
Co-authored-by: Claude Opus 4.6 <[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");
}
}