Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method createPact does not conform required method signature 'public au.com.dius.pact.core.model.V4Pact xxx(PactBuilder builder)' #1745

Closed
AbulSyed opened this issue Dec 8, 2023 · 1 comment

Comments

@AbulSyed
Copy link

AbulSyed commented Dec 8, 2023

I am following the pact doc: https://docs.pact.io/implementation_guides/jvm/consumer/junit5 to write a pact test.

  • build.gradle:
plugins {
	id 'java'
	id 'org.springframework.boot' version '3.1.2'
	id 'io.spring.dependency-management' version '1.1.2'
	id "au.com.dius.pact" version "4.4.9"
}

dependencies {
        ...
	testImplementation 'au.com.dius.pact.consumer:junit5:4.4.9'
}
...
test {
	useJUnitPlatform()
}
...
pact {
	publish {
		pactDirectory = "target/pacts"
		pactBrokerUrl = 'http://localhost:9292/'
	}
}
  • code (taken from above doc):
@ExtendWith(PactConsumerTestExt.class)
@PactTestFor(providerName = "ArticlesProvider")
class ExampleJavaConsumerPactTest {

    @Pact(provider="ArticlesProvider", consumer="test_consumer")
    public RequestResponsePact createPact(PactDslWithProvider builder) {
        return builder
                .given("test state")
                .uponReceiving("ExampleJavaConsumerPactTest test interaction")
                .path("/articles.json")
                .method("GET")
                .willRespondWith()
                .status(200)
                .body("{\"responsetest\": true}")
                .toPact();
    }

    @Test
    void test(MockServer mockServer) {
        System.out.println(mockServer.getUrl());
    }
}

When I run test, I get console error:

Method createPact does not conform required method signature 'public au.com.dius.pact.core.model.V4Pact xxx(PactBuilder builder)'
java.lang.UnsupportedOperationException: Method createPact does not conform required method signature 'public au.com.dius.pact.core.model.V4Pact xxx(PactBuilder builder)'

Assuming it's an issue with the versions of pact I'm using. What pact version should I use in my build.gradle - to get the above working?

@AbulSyed
Copy link
Author

AbulSyed commented Dec 9, 2023

Closing - going to update the createPact method to return V4Pact. Would be nice for docs to updated to reflect this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant