authorjapps / authorjapps/zerocode
[KAFKA] Assert record content when multiple records collected
- Dominant language
- Java
- Stars
- 1k
- Forks
- 453
- Avg merge
- 7d 2h
- Merged PRs (30d)
- 5
Description
Sometimes when I run consumer tests more than one record is picked up by the KafkaConsumer together with the one I'm looking for but AssertionProcessor only tries to match the first record collected.
Here is my consumer configuration :
```json
{
"scenarioName": "Check phoneNumbersChange even is generated",
"steps": [
{
"name": "consume_step",
"url": "kafka-topic:t1.party.customer.test.v1",
"operation": "consume",
"request": {
"consumerLocalConfigs": {
"recordType": "JSON",
"commitSync": true,
"showRecordsConsumed": true,
"maxNoOfRetryPollsOrTimeouts": 10
}
},
"assertions": {
"records": [
{
"key" : "37_party_customer_7C8012AC-0122-4911-8808-54AA687C0002",
"value": {
"metadata": {
"bankNr": 37,
"eventName":"phoneNumbersChanged"
},
"payload": {
"phoneNumberList": [
{
"description" : "Mobil",
"isMobilePhone" : true,
"phoneNumber" : "${SYSTEM.PROPERTY:37_phoneChange}"
}
]
}
}
}
]
}
}
]
}
```
KafkaConsumer then properly pick's up the records including mine with

but when then it continues to assertion phase it checks only for the first records

How can I fix this?
Contributor guide
Research direction
Start by tracing the records collected by KafkaConsumer into AssertionProcessor using the consumer configuration in the issue. Reproduce the case with multiple records, then verify that the assertion can match the expected key and value when it is not the first collected record.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kafka
- Domain
- stream-processing, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100