Spring Cloud Contract 4.0 No signature of method: messageFrom()

100 Views Asked by At

I'm doing a Java and Spring Boot upgrade for an application at the moment. Java 8 -> Java 17 Spring Boot 2.5.6 -> 3.1.0

It has used Spring Cloud Contract for contract tests so while upgrading Java, I also upgraded Groovy and Spring Cloud Contract dependencies as well. Bellow are the relevant dependencies.

    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy</artifactId>
        <version>3.0.19</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-xml</artifactId>
        <version>3.0.19</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-json</artifactId>
        <version>3.0.19</version>
        <scope>test</scope>
    </dependency>
        <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-contract-verifier</artifactId>
        <version>4.0.4</version>
        <scope>test</scope>
    </dependency>
        <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-contract-wiremock</artifactId>
        <version>4.0.4</version>
        <scope>test</scope>
    </dependency>

    <plugins>
        <plugin>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-contract-maven-plugin</artifactId>
            <version>4.0.4</version>
            <extensions>true</extensions>
            <configuration>
                <!-- Provide the base class for your auto-generated tests -->
                <testMode>EXPLICIT</testMode>
                <basePackageForTests>sample.contract</basePackageForTests>
                <baseClassForTests>sample.BaseContractClass</baseClassForTests>
            </configuration>
        </plugin>
    </plugins>

Groovy script :

Contract.make {

label 'create_customer'
input {
    messageFrom('crm_customer_events')
    messageBody([
        type: 'CREATE',
        customer: [
            firstName: 'Tester',
            lastName: 'Testerton'
        ]
    ])
    messageHeaders {
        header('contentType': 'application/json')
    }
   }
}

Now during the build I'm having below build error :

[ERROR] Failed to execute goal org.springframework.cloud:
spring-cloud-contract-maven-plugin:4.0.4:generateTests (default-generateTests) on project crm-service-app: 

Execution default-generateTests of goal org.springframework.cloud:spring-cloud-contract-maven-plugin:4.0.4:generateTests 
failed: groovy.lang.MissingMethodException: 

No signature of method: sample.createCustomerEvent.messageFrom() is applicable for argument types: 
(String) values: [crm_customer_events] -> [Help 1]

I couldnt see any documentation that saying syntax messageFrom has been changed. What could be the reason for this?

Thanks in advance.

0

There are 0 best solutions below