I have perfectly running Mock API server based on Karate. There is some custom Java code that I also want to execute when Scenario is matched.
Executing the Mock using jar as follows
java -jar karate-0.9.0.jar -m ./src/test/java/Mymock.feature -p 9000
Mymock.feature has something like follows
Scenario: pathMatches('/')
* def Signature = Java.type('Signature')
* def sign = Signature.calculate('382700b563f4', {'userId':'399645532', 'os':'android', 'client_key':'3c2cd3f3', 'token':'141a649988c946ae9b5356049c316c5d-838424771', 'token_client_salt':'d340a54c43d5642e21289f7ede858995'})
* print sign.sig
* print sign.__NStokensig
Code above works fine when executed directly via a Feature file.
But As expected this gives error if its invoked if embedded in Mocks.
Mymock.feature:70 - javascript evaluation failed: Java.type('Signature'), java.lang.ClassNotFoundException: Signature
How can I execute Java code embedded in mocks? I am not dependent on jar to execute Mocks so can easily try new way to execute Java Code in Mocks though any other method.