oscerd commented on code in PR #26499: URL: https://github.com/apache/camel/pull/26499#discussion_r4034150346
########## components/camel-huawei/camel-huaweicloud-smn/src/test/java/org/apache/camel/component/huaweicloud/smn/PublishTextMessageOperationViaPropertyTest.java: ########## @@ -0,0 +1,82 @@ +/* + * 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.component.huaweicloud.smn; + +import org.apache.camel.BindToRegistry; +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.huaweicloud.smn.constants.SmnOperations; +import org.apache.camel.component.huaweicloud.smn.constants.SmnProperties; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * When the operation is supplied only through the {@code CamelHwCloudSmnOperation} exchange property (with no + * {@code operation} endpoint parameter), an empty text-message body must fail with the clear + * {@code IllegalArgumentException} - not a {@code NullPointerException} from the guard testing the (null) endpoint + * operation, which was the behaviour before the operation was resolved ahead of the body check. + */ +public class PublishTextMessageOperationViaPropertyTest extends CamelTestSupport { + + TestConfiguration testConfiguration = new TestConfiguration(); + + @BindToRegistry("smnClient") + SmnClientMock smnClientMock = new SmnClientMock(null); + + protected RouteBuilder createRouteBuilder() { Review Comment: Done — added propertyOverridingTemplatedEndpointToTextRejectsEmptyBody covering scenario 2 (endpoint operation publishAsTemplatedMessage overridden by the property to publishAsTextMessage, empty body → clear IllegalArgumentException instead of a silently-published empty text message). _Claude Code on behalf of oscerd_ -- 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]
