gnodet-bot commented on code in PR #26446: URL: https://github.com/apache/camel/pull/26446#discussion_r4010408421
########## dsl/camel-kamelet-main/src/test/java/org/apache/camel/main/download/KameletOptimisedComponentResolverTest.java: ########## @@ -0,0 +1,65 @@ +/* + * 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 static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.kamelet.KameletComponent; +import org.apache.camel.impl.DefaultCamelContext; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class KameletOptimisedComponentResolverTest { + + private DefaultCamelContext context; + private KameletOptimisedComponentResolver resolver; + + @BeforeEach + void setUp() { + context = new DefaultCamelContext(); + resolver = new KameletOptimisedComponentResolver(context); + } + + @AfterEach + void tearDown() { + context.stop(); + } + + @Test + void shouldNotLoadTemplateFromLocationWhenKameletRegisteredAsBean() throws Exception { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + routeTemplate("myBeanKamelet") + .from("direct:in") Review Comment: Test scenario mismatch — declared bug not actually exercised. The JIRA (CAMEL-24746) and PR title describe kamelets registered via `@BindToRegistry` (dynamic compilation path in `AnnotationDependencyInjection`). This test uses `routeTemplate()` inside a `RouteBuilder`, which is a different registration path — it populates `Model.routeTemplateDefinitions` via `addRoutesToCamelContext` → `prepareModel` → `populateRouteTemplates`. The `@BindToRegistry` path goes through `AnnotationDependencyInjection.BindToRegistryCompilePostProcessor`, which calls the bean post-processor — it does NOT directly call `addRouteTemplateDefinitions`. Whether it ultimately populates `getRouteTemplateDefinition(name)` depends on the class being a `RouteBuilder` (picked up by `addRoutes`) or a plain bean — this is exactly what needs a test. The current test verifies the guard condition works in the general case, but it does not reproduce the declared regression. Either: 1. Add a test that mirrors the actual `@BindToRegistry` scenario (e.g. programmatically invoke the `BindToRegistryCompilePostProcessor` or simulate the dynamic compilation flow), **or** 2. Rename the test method to accurately describe what is actually tested (`shouldNotLoadTemplateFromLocationWhenTemplateInModel` or similar) and add a clarifying comment that the `@BindToRegistry` path also populates the model before reaching the resolver. -- 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]
