Hi All, I have a question. I have a contact in yam...
# general
k
Hi All, I have a question. I have a contact in yaml that has the request and response as seen below.. my stubs are returning current date in the 'availableCheckAmountDate' field. Is there a way for me to check the value in 'availableCheckAmountDate' against the current date in the contract instead of hardcoding a value ? I tried putting this availableCheckAmountDate: "${value(producer(today())}", however, this didn't help ? I was looking at the Wiremock documentation https://wiremock.org/docs/ and couldn't find any examples there
Copy code
request:
  method: GET
  urlPath: <masked>
  headers:
    Authorization: Bearer authorization
    nep-correlation-id: <masked>
    channel: ESS
  matchers:
    headers:
    - key: Authorization
      regex: Bearer \S+

response:
  status: 200
  headers:
    Content-Type: application/json
  body:
    accounts:
      - accountNumber: <masked>
         additionalInfo:
          encId: <masked>
          productDescription: <masked>
          relationshipTypeToAccount: <masked>
          standardProduct: <masked>
          subproduct: <masked>
        availableBalance: 1500000
        product: <masked>
        availableCredit: 1500000
        category: <masked>
        checksReceivedInfo:
          availableCheckAmountDate: '2025-07-07'
          availableCheckAmountThreshold: 4000
          availableCheckAmountTotal: 2000
          mappingId: <masked>
l
Sorry, I am not sure I understand the requirement. Are you wanting to put todays date in the
availableCheckAmountDate
field in the response? Also, just out of interest, where does this yaml come from? Are you using a specific wiremock implementation ?
k
Yes, I want to put today's date against the
availableCheckAmountDate
. Regarding the yaml, the contracts for the test are defined in yaml. I am using the wiremock-standalone 3.6.0 version
l
Have you looked at response templating ? There is the
{{now}}
template helper - https://wiremock.org/docs/response-templating/#date-and-time-helpers
3.6.0
is also quite old.
3.13.1
in the latest non beta version - https://wiremock.org/docs/standalone/java-jar/
k
Yes, I have this for while mocking the response, however, I was wondering is there anything that I can set in the contract file which will check the value against the current date ? For example, setting this
availableCheckAmountDate: {{now}}
does not work as I am getting an illegal start of expression error while generating the classes for the contract
l
Sorry, I don't really know what a contract file is. What are you using to convert the yaml to a class ?
k
Sorry, I apologies that I didn't mention this properly. It is a spring cloud contract that I am using with Wiremock. Anyways, for now i found a way around this. Thank you so much for your help.
🙌 1