Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vaue lookup tokens don't work in kakfa JSON value #660

Open
Tobolov opened this issue Apr 9, 2024 · 2 comments
Open

Vaue lookup tokens don't work in kakfa JSON value #660

Tobolov opened this issue Apr 9, 2024 · 2 comments

Comments

@Tobolov
Copy link

Tobolov commented Apr 9, 2024

Value lookup tokens such as $.stepname.querystr token don't work within a json value field of kafka a kafka record.
This is the case for both the produce and consume operations.

Scenario to replicate:

---
scenarioName: Demonstrate issue 2
steps:
  - name: create_app
    url: "kafka-topic:APP"
    operation: produce
    request:
      recordType: JSON
      records:
        - key: ${RANDOM.NUMBER}
          value:
            appId: $.create_app.request.records[0].key
            userId: ${RANDOM.NUMBER}
    verify:
      status: Ok
  - name: verify_app
    url: "kafka-topic:APP"
    operation: consume
    retry:
      max: 3
      delay: 1000 #ms
    request:
      consumerLocalConfigs:
        recordType: JSON
        commitSync: true
        showRecordsConsumed: true
        maxNoOfRetryPollsOrTimeouts: 3
    verify:
      size: 1
      records:
        - key:  $.create_app.request.records[0].key
          value:
            appId:  $.create_app.request.records[0].key
            userId:  $.create_app.request.records[0].value.userId

Actual record produced to Kafka:
Key: 4712019646354101240
Value:

{
	"appId": "$.create_app.request.records[0].key",
	"userId": "3430825975012614214"
}

Exception thrown:*

java.lang.RuntimeException: Assertion failed for :- 

[Demonstrate issue 2] 
	|
	|
	+---Step --> [verify_app] 

Failures:
--------- 
Assertion jsonPath '$.records[0].value.userId' with actual value '3430825975012614214' did not match the expected value '$.create_app.request.records[0].value.userId'
----------------------------------------------------------------------------------------------------------------------------------
Assertion jsonPath '$.records[0].key' with actual value '4712019646354101240' did not match the expected value '$.create_app.request.records[0].key'


	at org.jsmart.zerocode.core.runner.StepNotificationHandler.handleAssertionFailed(StepNotificationHandler.java:37)
	at org.jsmart.zerocode.core.runner.StepNotificationHandler.handleAssertion(StepNotificationHandler.java:71)
	at org.jsmart.zerocode.core.runner.ZeroCodeMultiStepsScenarioRunnerImpl.executeRetry(ZeroCodeMultiStepsScenarioRunnerImpl.java:316)
	at org.jsmart.zerocode.core.runner.ZeroCodeMultiStepsScenarioRunnerImpl.executeRetryWithSteps(ZeroCodeMultiStepsScenarioRunnerImpl.java:191)
	at org.jsmart.zerocode.core.runner.ZeroCodeMultiStepsScenarioRunnerImpl.executeSteps(ZeroCodeMultiStepsScenarioRunnerImpl.java:173)
	at org.jsmart.zerocode.core.runner.ZeroCodeMultiStepsScenarioRunnerImpl.runScenario(ZeroCodeMultiStepsScenarioRunnerImpl.java:136)
	at org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner.runLeafJsonTest(ZeroCodeUnitRunner.java:223)
	at org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner.runChild(ZeroCodeUnitRunner.java:127)
	at org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner.runChild(ZeroCodeUnitRunner.java:51)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner.run(ZeroCodeUnitRunner.java:107)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
@nirmalchandra
Copy link
Collaborator

nirmalchandra commented May 7, 2024

@Tobolov , Sounds like ${RANDOM.NUMBER.FIXED} might help in this case.

  • Doc link is here
  • Docs for other random-number-flavours are here

@authorjapps
Copy link
Owner

@Tobolov , can you check if this issue was solved by this PR?
If so, we can close this ticket.

@authorjapps authorjapps added this to the DENMARK-BAU-MINOR-RELEASE milestone Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants