Hi All, I have wiremock server setup for springbo...
# wiremock-java
a
Hi All, I have wiremock server setup for springboot restful apis. the server is started programmatically and uses json file based mappings to mock the response. i want to extend this to use a random value generated for long type. i tried with giving "{{randomValue type='NUMBER' min=1000 max=999999 asNumber=true}}" as value of property, It does not generate a number yet uses this string to assign to long, which is wrong. I tried to add a ResponseDefinitionTransformerV2 implementation but unable to create ResponseDefinition as json what is the best way to achieve random value as long type being generated
l
The randomValue should be the way to generate the random number. Can you paste your json here so I can try and see what is happening.
a
would this expression, packageId: "{{randomValue type='NUMBER' min=1000 max=999999 asNumber=true}}" generate a number or string. if pakageId is of long type in java object
l
It will only generate it as a string because you have wrapped it in quotes.
a
without quotes app startup fails complaining about invalid json
a
yes. i am using jsonBody
l
That will be the issue then. As it says in the link, you will need to switch to using body instead.
a
i am able to write custom implementation for ResponseDefinitionTransformerV2
l
Do you mean instead of moving to using the body element ?
a
yes, instead of using randomValue construct in json file I created a custom transformer and added as extension
l
Sure. I guess that is possible.