gnodet-bot commented on code in PR #26520:
URL: https://github.com/apache/camel/pull/26520#discussion_r4027904212


##########
dsl/camel-kamelet-main/src/test/java/org/apache/camel/main/download/DependencyDownloaderPropertiesFunctionResolverTest.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.main.download;
+
+import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.impl.engine.SimpleCamelContext;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Regression test for CAMEL-24776: a normal run (not only export) must 
auto-download the JAR that backs a secret
+ * properties function - e.g. camel-kubernetes for {@code {{secret:...}}} and 
{@code {{configmap:...}}} - so the
+ * function can be resolved. Otherwise the placeholder is silently parsed as a 
key with a default value and resolves to
+ * the wrong literal.
+ */
+public class DependencyDownloaderPropertiesFunctionResolverTest {
+
+    private static final String KUBERNETES = 
"org.apache.camel:camel-kubernetes";
+
+    @Test
+    void runDownloadsKubernetesForSecretFunction() {
+        assertTrue(resolveAndRecordDownloads(false, false, 
"secret").contains(KUBERNETES),
+                "run must auto-download camel-kubernetes for the secret 
function");
+    }
+
+    @Test
+    void runDownloadsKubernetesForConfigmapFunction() {
+        assertTrue(resolveAndRecordDownloads(false, false, 
"configmap").contains(KUBERNETES),
+                "run must auto-download camel-kubernetes for the configmap 
function");
+    }
+
+    @Test
+    void exportStillDownloadsKubernetesForSecretFunction() {
+        assertTrue(resolveAndRecordDownloads(true, false, 
"secret").contains(KUBERNETES),
+                "export must keep auto-downloading camel-kubernetes for the 
secret function");
+    }
+
+    @Test
+    void transformStubsWithoutDownloading() {
+        assertEquals(List.of(), resolveAndRecordDownloads(false, true, 
"secret"),

Review Comment:
   The test suite only covers the `secret` and `configmap` → `camel-kubernetes` 
path. The other four mappings in `downloadPropertiesFunctionDependency` — 
`base64` → `camel-base64`, `aws` → `camel-aws-secrets-manager`, `azure` → 
`camel-azure-key-vault`, `gcp` → `camel-google-secret-manager`, `hashicorp` → 
`camel-hashicorp-vault` — have no regression test here. If any of those 
mappings regress (e.g., function name typo, removed `if` branch), this test 
suite won't catch it.
   
   Consider adding at least one more test for a non-Kubernetes mapping, for 
example:
   ```java
   @Test
   void runDownloadsCamelBase64ForBase64Function() {
       assertTrue(resolveAndRecordDownloads(false, false, 
"base64").contains("org.apache.camel:camel-base64"),
               "run must auto-download camel-base64 for the base64 function");
   }
   
   @Test
   void runDownloadsAwsSecretsManagerForAwsFunction() {
       assertTrue(resolveAndRecordDownloads(false, false, 
"aws").contains("org.apache.camel:camel-aws-secrets-manager"),
               "run must auto-download camel-aws-secrets-manager for the aws 
function");
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to