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').
atiaomar1978-hub
left a comment
There was a problem hiding this comment.
Re-review summary
AI-generated re-review on behalf of atiaomar1978-hub (Bugbot + manual review)
All feedback from the prior review has been addressed in commits c8c2de0 and ad9a973. This looks ready to merge.
Prior feedback — resolved
- Map body schema documented —
alibaba-eventbridge-component.adocnow documents input Map keys (eventBusName,eventSource,eventType,eventSubject,eventData), response body structure, and examples for String/JSON, Map, and multi-event payloads. @MetadatajavaType mismatch —AlibabaEventBridgeConstantsis now plain dictionary-key constants (aligned withOSSConstants), with no incorrect@Metadataannotations on payload/response map keys.- Test coverage expanded —
testPutEventsWithListOfMapsAndSubjectAndEntryListcoverseventSubjectoverrides,List<Map>batch publishing, and fullentryListresponse assertions.
What looks good
- Clean separation:
AlibabaEventBridgeHeaders(exchange headers with@Metadata) vsAlibabaEventBridgeConstants(Map body/response keys). - Sealed
Headers→Propertieshierarchy deduplicates exchange header declarations without changing public constant names. - Utils and tests consistently use constants instead of magic strings.
- Map keys align with endpoint option naming (
eventSourcevs CloudEvents-shortsource) — sensible for a Preview component not yet released.
Bugbot
No bugs found on latest diff.
Non-blocking notes
- Manual header tables in the adoc overlap with
include::partial$component-endpoint-headers.adoc[]— fine for now; could dedupe later if generated docs stay in sync. - Sealed header hierarchy differs from other Alibaba modules (OSS/KMS use separate
finalclasses) — acceptable for EventBridge; no need to block.
Verdict
Approved — thanks @arunsrajan for the thorough follow-up commits.
Review performed with code inspection and Bugbot. Does not replace specialized tools (CodeRabbit, Sourcery, SonarCloud).
| /** | ||
| * Constants for Alibaba EventBridge payload and response dictionary keys. | ||
| */ | ||
| public final class AlibabaEventBridgeConstants { |
There was a problem hiding this comment.
Resolved — plain constants, no incorrect @metadata
Good follow-up: payload and response dictionary keys are now plain String constants with class-level Javadoc, matching OSSConstants. This removes the prior javaType mismatches on failedEntryCount and entryList.
|
|
||
| |======================================================================= | ||
|
|
||
| === Event payload Map keys evaluated by the producer |
There was a problem hiding this comment.
Resolved — Map body schema documented
Input Map keys, response metadata structure, and String/JSON + Map + multi-event examples are all documented. Prior concern about the source→eventSource rename is mitigated since this is a Preview 4.23 component not yet released.
| } | ||
|
|
||
| @Test | ||
| void testPutEventsWithListOfMapsAndSubjectAndEntryList() throws Exception { |
There was a problem hiding this comment.
Resolved — expanded test coverage
testPutEventsWithListOfMapsAndSubjectAndEntryList covers eventSubject overrides, batch List<Map> publishing, and full entryList response metadata assertions. Good AssertJ usage throughout.
Re-review completeAI-generated on behalf of atiaomar1978-hub Verdict: Approved All prior review feedback has been addressed:
Bugbot found no issues on the latest diff. LGTM — thanks @arunsrajan! |
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.