gnodet-bot commented on code in PR #26446: URL: https://github.com/apache/camel/pull/26446#discussion_r4042877243
########## 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 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; + +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertThrows; + +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 shouldNotLoadTemplateFromLocationWhenTemplateInModel() throws Exception { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + routeTemplate("myBeanKamelet") + .from("direct:in") + .to("mock:out"); + } + }); + + var answer = resolver.resolveComponent("kamelet:myBeanKamelet"); + + assertInstanceOf(KameletComponent.class, answer); + } + + @Test + void shouldLoadTemplateFromLocationWhenKameletNotRegisteredAsBean() { Review Comment: Nit: this name (`WhenKameletNotRegisteredAsBean`) uses the old "registered as bean" phrasing that was just renamed away in the first method. Suggest aligning with the new naming style: ```suggestion void shouldLoadTemplateFromLocationWhenTemplateNotInModel() { ``` ########## 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 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; + +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertThrows; + +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 shouldNotLoadTemplateFromLocationWhenTemplateInModel() throws Exception { Review Comment: Missing clarifying comment — the previous review asked for a rename **and** a comment explaining that the `@BindToRegistry` path also populates `Model.routeTemplateDefinitions` before the resolver is called, making `routeTemplate()` in a `RouteBuilder` a valid proxy for the actual regression scenario. ```suggestion // Note: @BindToRegistry kamelets are also registered via Model.routeTemplateDefinitions // (through AnnotationDependencyInjection → addRoutes → prepareModel → populateRouteTemplates), // so this RouteBuilder-based registration exercises the same guard as the declared regression. void shouldNotLoadTemplateFromLocationWhenTemplateInModel() throws Exception { ``` -- 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]
