title: Wiremock returning wrong content-type for Spring Cloud Contract stub runner
body: <p>I'm trying out Spring-Cloud-Contract for the first time. I'm trying to have my client auto-discover the contract stubs, but even though my contract specifies a content-type of 'application/json' on the response, what I get from WireMock has a content-type of 'application/octet'. What am I doing wrong?</p>
  
  <p>I have a simple method in my service which returns a model like this from a <code>/status</code> endpoint:</p>
  
  <pre><code>{
    "name": string,
    "status": string
  }
  </code></pre>
  
  <p>My contract looks like this:</p>
  
  <pre><code>import org.springframework.cloud.contract.spec.Contract
  
  Contract.make {
      request {
          method('GET')
          headers {
              contentType(applicationJson())
          }
          url("/status")
      }
  
      response {
          status OK()
          body(
                  name: "Demo",
                  status: "RUNNING"
          )
          headers {
              contentType(applicationJson())
          }
      }
  }
  </code></pre>
  
  <p>In my client, I have a class which uses a Spring <code>RestTemplate</code> to query this endpoint:</p>
  
  <pre><code>@Component
  public class StatusClient {
  
      private final RestTemplate restTemplate;
  
      public StatusClient(RestTemplate restTemplate) {
          this.restTemplate = restTemplate;
      }
  
      public Status getStatus() {
          return this.restTemplate
                  .exchange("http://localhost:8080/status", HttpMethod.GET, null, Status.class)
                  .getBody();
      }
  }
  
  @Data
  class Status implements Serializable {
      private String name;
      private String status;
  }
  </code></pre>
  
  <p>My unit test uses <code>@AutoConfigureStubRunner</code> to pull the latest version of the contract from the local repository and assert against the response from the contract (eg name = Demo, status = RUNNING).</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  @AutoConfigureStubRunner(ids = {"com.example:contract-demo:+:8080"}, stubsMode = StubRunnerProperties.StubsMode.LOCAL)
  public class StatusClientTests {
  
      @Autowired
      private StatusClient client;
  
      @Test
      public void testThatStatusReturnsSuccessfully() {
          Status result = this.client.getStatus();
          assertEquals("Demo", result.getName());
          assertEquals("RUNNING", result.getStatus());
      }
  }
  </code></pre>
  
  <p>When I run the test, WireMock reports the contract it received as expected:</p>
  
  <blockquote>
  <pre><code>2018-05-31 11:36:49.919  INFO 14212 --- [tp1255723887-26] WireMock                                 : Request received:
  127.0.0.1 - GET /status
  
  User-Agent: [Java/1.8.0_161]
  Connection: [keep-alive]
  Host: [localhost:8080]
  Accept: [application/json, application/*+json]
  
  
  
  Matched response definition:
  {
    "status" : 200,
    "body" : "{\"name\":\"Demo\",\"status\":\"RUNNING\"}",
    "headers" : {
      "contentType" : "application/json"
    },
    "transformers" : [ "response-template" ]
  }
  
  Response:
  HTTP/1.1 200
  contentType: [application/json]
  </code></pre>
  </blockquote>
  
  <p>But when the RestTemplate tries to deserialize it, it throws an exception because the response content type is actually "application/octet" once it hits the methods to extract the data:</p>
  
  <pre><code>org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class com.example.contractclientdemo.Status] and content type [application/octet-stream]
  
      at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:119)
      at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:991)
      at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:974)
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:725)
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:680)
      at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:600)
      at com.example.contractclientdemo.StatusClient.getStatus(StatusClient.java:18)
  </code></pre>
  
  <p>I'm using Finchley.RC2 for the Spring cloud version, and <code>spring-cloud-starter-contract-stub-runner</code> is my only test dependency other than <code>spring-boot-starter-test</code>.</p>
  
  <p>I know WireMock is returning the wrong content type because I debugged deep into the HttpMessageConverterExtractor class in Spring and that's what the <code>getContentType</code> method returned when queried.</p>
  
  <p>Why is WireMock returning the wrong content type, though it reports the correct one in the log? And how can I get it to properly return an <code>application/json</code> so I can deserialize my simple message?</p>