Rishav Singh
05/14/2025, 3:49 PMjava.lang.UnsupportedOperationException: Method createPact does not conform required method signature 'public au.com.dius.pact.core.model.V4Pact xxx(PactBuilder builder)'
at au.com.dius.pact.consumer.junit.JUnitTestSupport.conformsToSignature(JUnitTestSupport.kt:35)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.lookupPact(PactConsumerTestExt.kt:504)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.setupPactForTest(PactConsumerTestExt.kt:270)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.setupMockServerForProvider(PactConsumerTestExt.kt:248)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.beforeTestExecution(PactConsumerTestExt.kt:223)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)rholshausen
05/14/2025, 11:01 PMPactBuilder as the only parameter and return a V4Pact?Matt (pactflow.io / pact-js / pact-go)
Rishav Singh
05/15/2025, 5:04 AMRishav Singh
05/15/2025, 5:05 AM@ExtendWith(PactConsumerTestExt.class)
@PactTestFor(providerName = "rules-api-bi", pactVersion = PactSpecVersion.V4)
class RulesApiConsumerTest {
@Pact(consumer = "fanout-logs-bi")
public V4Pact createPact(PactBuilder builder) {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
// Create a sample Rule object
PactDslJsonArray rule = ((PactDslJsonArray) ((PactDslJsonArray) new PactDslJsonBody()
.booleanType("active", true)
.stringType("createdBy")
.datetime("createdAt")
.stringType("updatedBy")
.datetime("updatedAt")
.stringType("deletedBy")
.datetime("deletedAt")
.uuid("ruleId")
.stringType("name")
.stringType("description")
.booleanType("isCustomerRule", true)
.stringType("customerId")
.minArrayLike("dataTypes", 1, new PactDslJsonRootValue(), 1)
.booleanType("shouldMatchAllRecords", true)
.object("ruleCondition")
.stringType("additionalProp1")
.stringType("additionalProp2")
.stringType("additionalProp3")
.closeObject())
.stringType("connectionType")
.stringType("outputTopic")
.object("configuration")
.stringType("additionalProp1")
.stringType("additionalProp2")
.stringType("additionalProp3")
.closeObject()
.object("targetConfiguration")
.stringType("additionalProp1")
.stringType("additionalProp2")
.stringType("additionalProp3")
.closeObject())
.uuid("ruleDestinationId")
.uuid("destinationAuthenticationId")
.booleanType(true);
return builder
.usingLegacyDsl()
.given("Rules exist")
.uponReceiving("A request for rules with includeInactive=true")
.path("/v2/rules")
.method("GET")
.query("includeInactive=false")
.willRespondWith()
.status(200)
.headers(headers)
.body(rule)
.toPact(V4Pact.class);
}
@Test
@PactTestFor(pactMethod = "createPact")
void testRulesEndpoint(MockServer mockServer) {
String baseUrl = mockServer.getUrl();
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<Rule[]> response = restTemplate.getForEntity(baseUrl + "/v2/rules", Rule[].class);
// Assert
assertEquals(200, response.getStatusCode().value());
}
}Rishav Singh
05/15/2025, 5:12 AMjava.lang.AssertionError: The following methods annotated with @Pact were not executed during the test: RulesApiConsumerTest.createPact
If these are currently a work in progress, add a @Disabled annotation to the method
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.afterAll(PactConsumerTestExt.kt:720)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)Rishav Singh
05/15/2025, 8:26 AMRishav Singh
05/15/2025, 8:26 AMRishav Singh
05/15/2025, 7:11 PM