CAMEL-24373: Refactor camel-alibaba-eventbridge constants, headers and - #25552
CAMEL-24373: Refactor camel-alibaba-eventbridge constants, headers and#25552arunsrajan wants to merge 3 commits into
Conversation
tests
Refactor constant definitions and test assertions in the Alibaba Cloud
EventBridge component to improve maintainability, follow Camel
conventions,
and fix unit test execution:
1. Constants and Header Hierarchy:
- Introduce AlibabaEventBridgeConstants for event payload field keys
(eventBusName, eventSource, eventType, eventSubject, eventData) and
response dictionary keys.
- Refactor AlibabaEventBridgeHeaders into a sealed class permitted
for
AlibabaEventBridgeProperties, centralizing common Camel header
names
and avoiding duplicate field declarations.
- Update AlibabaEventBridgeHeaders constructor to package-private
visibility to allow the permitted subclass to extend it.
2. Utils Alignment:
- Update AlibabaEventBridgeUtils to use AlibabaEventBridgeConstants
for resolving CloudEvent fields and structuring response maps.
3. Test Fixes:
- Update PutEventsTest to use AlibabaEventBridgeConstants for Map
body
keys, ensuring event data is properly extracted and serialized.
- Fix Map assertion keys against response metadata constants.
- Verify all unit tests pass with Mockito and Camel Test framework.
atiaomar1978-hub
left a comment
There was a problem hiding this comment.
Review summary
AI-generated review on behalf of atiaomar1978-hub (Bugbot + manual review)
Focused refactor — centralizing map-body and response keys in AlibabaEventBridgeConstants and deduplicating header/property definitions via the sealed AlibabaEventBridgeHeaders → AlibabaEventBridgeProperties hierarchy is the right direction for maintainability.
What looks good
- Response map keys unchanged at runtime (
requestId,failedEntryCount, etc.) — only centralized behind constants. PutEventsTestupdated to use the new map-body keys consistently.- Header/property Camel-prefixed names preserved — no exchange-header breaking change.
- Aligning map keys with URI parameter names (
eventSource,eventType, …) is clearer than the previous CloudEvents-short names (source,type).
Issues to address
-
Map body key rename — keys changed from
source/type/subject/datatoeventSource/eventType/eventSubject/eventData. Fine while Preview/unreleased; document the Map body schema inalibaba-eventbridge-component.adoc. -
@MetadatajavaType accuracy —EVENT_RESPONSE_FAILED_ENTRY_COUNTandEVENT_RESPONSE_ENTRY_LISTannotated asStringbut producer putsIntegerandList<Map<…>>. -
@Metadataon map-body constants — these are Map payload fields, not exchange headers. Consider plain constants like OSSOSSConstants. -
Test gaps (minor) — consider
eventSubjectin map body, list-of-maps body, responseentryListstructure.
Verdict
Comment — good refactor, merge-ready after doc + metadata polish. No functional bugs found by Bugbot.
Review performed with code inspection and Bugbot.
| String data = jsonDataValue(mapBody.get("data")); | ||
| String eventBusName | ||
| = stringValue(mapBody.get(AlibabaEventBridgeConstants.EVENT_BUS_NAME), configuration.getEventBusName()); | ||
| String source = stringValue(mapBody.get(AlibabaEventBridgeConstants.EVENT_SOURCE), configuration.getEventSource()); |
There was a problem hiding this comment.
Map body keys renamed — document this
Previous Map keys were CloudEvents-short (source, type, subject, data); now aligned with URI params (eventSource, eventType, eventSubject, eventData). Fine for unreleased Preview, but please document the Map body schema in the component guide.
| @Metadata(label = "producer", description = "Event resource owner account identifier", javaType = "String") | ||
| public static final String EVENT_RESPONSE_RESOURCE_OWNER_ACCOUNT_IDENTIFIER = "resourceOwnerAccountId"; | ||
|
|
||
| @Metadata(label = "producer", description = "Event failed entry count", javaType = "String") |
There was a problem hiding this comment.
@Metadata javaType mismatch
EVENT_RESPONSE_FAILED_ENTRY_COUNT stores an Integer from getFailedEntryCount(). EVENT_RESPONSE_ENTRY_LIST is a List<Map<String,Object>>, not a String. Please fix javaType for catalog accuracy.
| import org.apache.camel.spi.Metadata; | ||
|
|
||
| public final class AlibabaEventBridgeHeaders { | ||
| public sealed class AlibabaEventBridgeHeaders permits AlibabaEventBridgeProperties { |
There was a problem hiding this comment.
Sealed hierarchy — consider consistency
Sealed Headers → Properties deduplicates exchange keys nicely. Other Alibaba modules (OSS, KMS, SMS) use separate final classes. Worth aligning across CAMEL-24373 if a convention is emerging.
| event.put("source", testConfiguration.getProperty("eventSource")); | ||
| event.put("type", testConfiguration.getProperty("eventType")); | ||
| event.put("data", Map.of("key", "value")); | ||
| event.put(AlibabaEventBridgeConstants.EVENT_BUS_NAME, testConfiguration.getProperty("eventBusName")); |
There was a problem hiding this comment.
Tests updated correctly
Map body test now uses AlibabaEventBridgeConstants keys. Minor gap: no coverage for eventSubject override or multi-event list body — non-blocking for this refactor.
Review completeAI-generated on behalf of atiaomar1978-hub Verdict: Comment — solid constants refactor, no blocking bugs. Bugbot flagged metadata Test coverage is adequate for the scope (string body + map body paths updated). Thanks @arunsrajan for keeping response map runtime keys stable while centralizing constants. |
document headers and map keys Address pull request feedback on the Alibaba Cloud EventBridge component: 1. Metadata Accuracy: - Correct `@Metadata` `javaType` on `EVENT_RESPONSE_FAILED_ENTRY_COUNT` from `String` to `Integer`. - Correct `@Metadata` `javaType` on `EVENT_RESPONSE_ENTRY_LIST` from `String` to `List<Map<String, Object>>`. - Add class-level Javadoc to `AlibabaEventBridgeConstants`. 2. Component Documentation: - Document message headers evaluated and set by the EventBridge producer in `alibaba-eventbridge-component.adoc`. - Document the input Map body schema and keys (`eventBusName`, `eventSource`, `eventType`, `eventSubject`, `eventData`). - Document response metadata structure returned in the message body (`requestId`, `resourceOwnerAccountId`, `failedEntryCount`, `entryList`). - Add examples for String/JSON payload, Map payload, and multiple-event publishing.
map schema, and expand test coverage Address pull request review feedback for the Alibaba Cloud EventBridge component: 1. Constants Refactoring: - Convert 'AlibabaEventBridgeConstants' to plain constants without '@metadata' annotations, aligning with 'OSSConstants' since these represent payload dictionary and response map keys rather than Camel exchange headers. - Add class-level Javadoc. 2. Component Documentation: - Document message headers evaluated and set by the EventBridge producer in 'alibaba-eventbridge-component.adoc'. - Document the input Map body schema and keys ('eventBusName', 'eventSource', 'eventType', 'eventSubject', 'eventData'). - Document response metadata structure in the message body ('requestId', 'resourceOwnerAccountId', 'failedEntryCount', 'entryList'). - Add examples for String/JSON payload, Map payload, and multi-event publishing. 3. Test Coverage: - Add 'testPutEventsWithListOfMapsAndSubjectAndEntryList' in 'PutEventsTest' to test 'eventSubject' overrides in Map payloads, batch multi-event publishing ('List<Map<String, Object>>'), and full assertions on response 'entryList' metadata ('eventId', 'errorCode', 'errorMessage').
tests
Refactor constant definitions and test assertions in the Alibaba Cloud EventBridge component to improve maintainability, follow Camel conventions,
and fix unit test execution:
Constants and Header Hierarchy:
AlibabaEventBridgeProperties, centralizing common Camel header names
and avoiding duplicate field declarations.
Utils Alignment:
Test Fixes:
keys, ensuring event data is properly extracted and serialized.
Description
Target
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.AI-assisted contributions
Co-authored-bytrailers) and the PR description identifies the AI tool used.