[KAFKA]Cannot inject ZeroCode variables into Validators
See original GitHub issueDescription:
This is my usecase:
Details were already provided initially. Copy pasting it again
- Consuming from Kafka multiple messages which are from different partitions.
- Need to validate the ID field of each message consumed. This ID is Random.Number generated in a previous test (REST POST).
- Trying to access this ID deterministically using validators and it is not working. Below is the validator being used. While consuming we are trying to validate the ID of the message consumed.
{
"name": "consume_from_test-topic",
"url": "kafka-topic:test-topic",
"operation": "consume",
"request": {
"consumerLocalConfigs": {
"recordType": "JSON",
"commitSync": false,
"showRecordsConsumed": true,
"maxNoOfRetryPollsOrTimeouts": 2
}
},
"validators": [
{
"field": "$..journals[?(@.id==${$.send_valid_unique_identifiers.response.body.rawJournals.[0].id})]",
"value": "${$.send_valid_unique_identifiers.response.body.rawJournals.[0].id}"
}
]
}
This is my actual request and actual response
Paste a sample or example here:
Complete logs already attached, as previously requested.
This is what I want to assert or validate
Paste a sample or example here:
Need to validate the value of ID field of each message consumed. This ID is Random.UUID Number generated in a previous test (REST POST)
Further details:
@authorjapps Scenario:
- Consuming from Kafka multiple messages which are from different partitions.
- Need to validate the ID field of each message consumed. This ID is Random.Number generated in a previous test (REST POST).
- Trying to access this ID deterministically using validators and it is not working. Below is the validator being used. While consuming we are trying to validate the ID of the message consumed.
{
"name": "consume_from_test-topic",
"url": "kafka-topic:test-topic",
"operation": "consume",
"request": {
"consumerLocalConfigs": {
"recordType": "JSON",
"commitSync": false,
"showRecordsConsumed": true,
"maxNoOfRetryPollsOrTimeouts": 2
}
},
"validators": [
{
"field": "$..journals[?(@.id==${$.send_valid_unique_identifiers.response.body.rawJournals.[0].id})]",
"value": "${$.send_valid_unique_identifiers.response.body.rawJournals.[0].id}"
}
]
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (4 by maintainers)
Top Results From Across the Web
Angular 4: using component variables inside custom validator ...
Class methods do not have this bound to the current instance, they are dependent on the caller to pass the appropriate this to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you, great job. Will review and merge soon.
Final bit and help needed when you get chance: Would you mind adding a basic helloword-type example for this please into the Docs?
This will be very useful for most users.
Already did understand what is needed:
The assertion to check here, that the data that was put on the backend rest server, is the same as received from the kafka topic. That is why it was tried to match the outcome of the kafka topic with the request to the backend rest server and because order may be different for the records, the jsonpath matcher in the “field” was used to get the correct record (
$..journals[?(@.id==${$.send_valid_unique_identifiers.response.body.rawJournals.[0].id})]
which means get the record with an id that matches with the original request list the first one’s id) and then perform a (second imo unnecessary because if the jsonpath matching above is not getting a result, it doesn’t exist and if is matches, then we know the outcome too) check with the value (${$.send_valid_unique_identifiers.response.body.rawJournals.[0].id}.
which means the value of the original request list the first one’s id)… Right?