kotlinpactmatcher

Date format in PACT-Test is ignored and fails (Java 17)


We have an issue that after migration some Pact tests fail. It seems that the test ignores the matching rule for the date in contract.

Matching rule:

          "$.entity.month": {
            "matchers": [
              {
                "match": "date",
                "format": "yyyy-MM"
              }
            ],

Maven dependency for Pact:

        <dependency>
            <groupId>au.com.dius.pact</groupId>
            <artifactId>consumer</artifactId>
            <version>4.1.24</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>au.com.dius.pact.consumer</groupId>
            <artifactId>java8</artifactId>
            <version>4.1.24</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>au.com.dius.pact.consumer</groupId>
            <artifactId>junit5</artifactId>
            <version>4.1.24</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>au.com.dius.pact.provider</groupId>
            <artifactId>junit5</artifactId>
            <version>4.1.24</version>
            <scope>test</scope>
        </dependency>

The tested event has a field in format "yyyy-mm". However, I get the following output:

    1.1) body: $.entity.month Expected "2023-02" to match a date of 'yyyy-MM-dd': Unable to parse the date: 2023-02

It seems that the field "format" of matcher is just ignored and the test expects a date in standard format.

I have tried to change the version of pact provider and consumer. But it didn't help at all. Can it be a Java version issue?

Expected behaviour: the test is green.


Solution

  • The issue was solved after I changed the version to 4.1.41.