NoSuchMethodError on PactDslJsonBody.booleanType
See original GitHub issueIf booleanType
is called in object
in array
, NoSuchMethodError
is thrown.
I got this error with “au.com.dius.pact.consumer:java8:4.1.17” and “au.com.dius.pact.consumer:junit5:4.2.0”.
This test code below can reproduce the error.
@ExtendWith(PactConsumerTestExt::class)
internal class BooleanTypeFailingTest {
@Pact(provider = "serviceA", consumer = "serviceB")
fun pact(builder: PactDslWithProvider): RequestResponsePact {
return builder
.given("foo")
.uponReceiving("bar")
.path("/v1/test")
.method("POST")
.body(
LambdaDsl.newJsonBody {
it.array("array") { array ->
array.`object` { obj ->
obj.booleanType("boolean1", true)
}
}
}.build()
)
.willRespondWith()
.status(200)
.toPact()
}
@Test
@PactTestFor(providerName = "serviceA", port = "0", pactMethod = "pact")
fun configDomain(mockServer: MockServer) {
}
}
stacktrace:
'au.com.dius.pact.consumer.dsl.PactDslJsonBody au.com.dius.pact.consumer.dsl.PactDslJsonBody.booleanType(java.lang.String, java.lang.Boolean)'
java.lang.NoSuchMethodError: 'au.com.dius.pact.consumer.dsl.PactDslJsonBody au.com.dius.pact.consumer.dsl.PactDslJsonBody.booleanType(java.lang.String, java.lang.Boolean)'
at io.pactfoundation.consumer.dsl.LambdaDslObject.booleanType(LambdaDslObject.java:178)
at BooleanTypeFailingTest$pact$1$1$1.accept(BooleanTypeFailingTest.kt:25)
at BooleanTypeFailingTest$pact$1$1$1.accept(BooleanTypeFailingTest.kt:12)
at io.pactfoundation.consumer.dsl.LambdaDslJsonArray.object(LambdaDslJsonArray.java:35)
at BooleanTypeFailingTest$pact$1$1.accept(BooleanTypeFailingTest.kt:24)
at BooleanTypeFailingTest$pact$1$1.accept(BooleanTypeFailingTest.kt:12)
at io.pactfoundation.consumer.dsl.LambdaDslObject.array(LambdaDslObject.java:588)
at BooleanTypeFailingTest$pact$1.accept(BooleanTypeFailingTest.kt:23)
at BooleanTypeFailingTest$pact$1.accept(BooleanTypeFailingTest.kt:12)
at io.pactfoundation.consumer.dsl.LambdaDsl.newJsonBody(LambdaDsl.java:75)
at BooleanTypeFailingTest.pact(BooleanTypeFailingTest.kt:22)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
at org.junit.platform.commons.support.ReflectionSupport.invokeMethod(ReflectionSupport.java:198)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.lookupPact(PactConsumerTestExt.kt:345)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.setupMockServer(PactConsumerTestExt.kt:245)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.beforeTestExecution(PactConsumerTestExt.kt:233)
...snip
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
How to use PactDslJsonBody in au.com.dius.pact.consumer.dsl
<init>. Constructs a new body as a child as a copy of an existing one · stringType. Attributes that can be any string...
Read more >NoSuchMethodException when using SpringRestPactRunner
I am using SpringRestPactRunner for the pact provider test. In the build.gradlew, I have put testImplementation 'au.com.dius:pact-jvm-provider- ...
Read more >Provides a DSL for use with Java to build consumer pacts.
Building JSON bodies with PactDslJsonBody DSL ... booleanType, Will match all boolean values (true and false).
Read more >PactDslJsonBody (pact-jvm-consumer-junit_2.11 2.2.0 API)
PactDslJsonBody · arrayLike(java.lang.String name). Array field where each element must match the following object. PactDslJsonBody · booleanType(java.lang.
Read more >How to Fix java.lang.NoSuchMethodError in Java - Rollbar
A java.lang.NoSuchMethodError is a runtime error which occurs when a method is called that exists at compile time, but does not exist at ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah!
au.com.dius.pact.consumer:java8
has been merged intoau.com.dius.pact:consumer:4.2.0
, just remove that dependency.When moving from
testImplementation 'au.com.dius.pact.consumer:junit5:4.1.39'
totestImplementation 'au.com.dius.pact.consumer:junit5:4.2.0'
the dependency oftestImplementation 'au.com.dius.pact.consumer:junit5:4.1.39
oftestImplementation 'au.com.dius.pact.consumer:java8:4.1.39
can be removed by changing the importse.g these imports in the code
can be changed to