0

Just trying to understand pact. We are using spring boot, so naturally I went to trying simple setup using pact-jvm-provider-spring-mvc. My pact file is a simple { "consumer": { "name": "MyConsumer" }, "provider": { "name": "MyProvider" }, "interactions": [ { "description": "a request for projects", "providerState": "i have a list of projects", "request": { "method": "GET", "path": "/dogs", "headers": { "Accept": "application/json" } }, "response": { "status": 200, "headers": { "Content-Type": "application/json" }, "body": [ { "dog": "1" } ] } } ], "metadata": { "pactSpecification": { "version": "2.0.0" } } } I added these dependencies to my gradle build:

```

testCompile group: 'com.reagroup', name: 'pact-jvm-provider-spring-mvc_2.10', version: '0.4.0' testCompile group: 'au.com.dius', name: 'pact-jvm-provider_2.10', version: '2.4.18' testCompile group: 'au.com.dius', name: 'pact-jvm-provider-junit_2.11', version: '3.4.1' ```

The test class doesn't do much, just creates a controller in spring fashion.

But what I get from running it is

```

org.json4s.package$MappingException: Case classes defined in function bodies are not supported.

at org.json4s.reflect.package$.fail(package.scala:96)
at org.json4s.reflect.Reflector$ClassDescriptorBuilder$$anonfun$9.apply(Reflector.scala:115)
at org.json4s.reflect.Reflector$ClassDescriptorBuilder$$anonfun$9.apply(Reflector.scala:115)
at scala.util.control.Exception$Catch$$anon$2.apply(Exception.scala:137)
at scala.util.control.Exception$Catch$$anon$2.apply(Exception.scala:135)
at scala.util.control.Exception$Catch.apply(Exception.scala:106)
at org.json4s.reflect.Reflector$ClassDescriptorBuilder.constructorsAndCompanion(Reflector.scala:115)
at org.json4s.reflect.Reflector$ClassDescriptorBuilder.result(Reflector.scala:156)
at org.json4s.reflect.Reflector$.createDescriptor(Reflector.scala:50)
at org.json4s.reflect.Reflector$$anonfun$describe$1.apply(Reflector.scala:44)
at org.json4s.reflect.Reflector$$anonfun$describe$1.apply(Reflector.scala:44)
at org.json4s.reflect.package$Memo.apply(package.scala:39)
at org.json4s.reflect.Reflector$.describe(Reflector.scala:44)
at org.json4s.Extraction$.extract(Extraction.scala:330)

```

It seems like a bug in the underlying jar file which is resolved. But I am just wondering if this is the right approach, can I simply bump the jar version for json4s? The pact-jvm-provider-spring-mvc is not touched in a while, and the 0.5.0 version never released. Again note that I don't need spring-mvc. I just want to test Pact against my rest api. I thought there might be another way of doing this.

Arash
  • 11,697
  • 14
  • 54
  • 81

1 Answers1

0

Make sure the request body matches what the api expects.

I've gotten similar errors (but from jackson) when that was the case.

Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
Jeppz
  • 912
  • 1
  • 8
  • 31