1

Why am i getting request match error in wiremock

"request": {
    "method": "GET",
    "urlPath": "/abc/v1",

    "queryParams": {
      "FromDate": {
        "equalToDateTime": "now -1 months",
        "actualFormat": "dd/MM/yyyy",
        "truncateExpected": "first hour of day"
      },

      "ToDate": {
        "equalToDateTime": "now -1 days",
        "actualFormat": "dd/MM/yyyy",
        "truncateExpected": "first hour of day"
      }
    }
  }

i get the following error

Query: FromDate [equalToDateTime] now -1 months<<<<< Query does not match
Query: ToDate [equalToDateTime] now -1 days<<<<< Query does not match

The data type for FromDate and ToDate is org.joda.time.LocalDate;

aron
  • 17
  • 1
  • 4
  • What does your request look like? I would be worried about [timezones](https://github.com/wiremock/wiremock/blob/70c32a330f2fdbc2748bcb4e25c09fa42af637fe/src/main/java/com/github/tomakehurst/wiremock/matching/EqualToDateTimePattern.java#L79) like `now` on the wiremock server might be a different day than you expect. Also maybe there's some difference in your interpretation of `now -1 months`? Here's how wiremock is [shifting time](https://github.com/wiremock/wiremock/blob/70c32a330f2fdbc2748bcb4e25c09fa42af637fe/src/main/java/com/github/tomakehurst/wiremock/common/DateTimeOffset.java#L79). – roby Jun 23 '22 at 04:07
  • Can you share the full request you're making? This one worked for me: `http://localhost:8080/abc/v1?FromDate=23/05/2022&ToDate=22/06/2022` – Tom Jun 23 '22 at 10:53
  • My full request is : localhost:8080/abc/v1?FromDate=2022-05-23&ToDate=2022-06-23 – 2022 and Here the data type of FromDate and ToDate is of type org.joda.time.LocalDate; – aron Jun 24 '22 at 08:24

0 Answers0