title: Generating Stubs by Using REST Docs not working with multipart/form-data
body: <p>I would like to automatically generate WireMock Stubs by using REST Docs. I want to match <code>multipart/form-data</code> request more precisely by using <code>WireMockRestDocs.verify()</code>, but I always get exception <code>[wiremock did not match request]</code>. My API has a method that combine two parts: json object and MultipartFile. What is wrong?</p>
  
  <pre><code>spring-boot 2.0.6.RELEASE
  spring-cloud-dependencies Finchley.SR2
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>@RestController
  public class MultipartTestController {
  
      private final Log logger = LogFactory.getLog(getClass());
  
      @PostMapping("/test")
      public ResponseEntity&lt;Void&gt; postMultipart(@RequestPart("metadata") MetadataDTO metadataDTO, @RequestPart("file") MultipartFile multipartFile) {
          logger.info(metadataDTO);
          return ResponseEntity.noContent().build();
      }
  }
  </code></pre>
  
  <p><strong>Test</strong></p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  @AutoConfigureRestDocs(outputDir = "target/generated-snippets")
  @AutoConfigureMockMvc
  public class DemoRestdocMultipartApplicationTests {
  
      @Autowired
      private MockMvc mockMvc;
  
      @Autowired
      private ObjectMapper objectMapper;
  
      @Test
      public void contextLoads() throws Exception {
  
          MetadataDTO metadataDTO = new MetadataDTO();
          metadataDTO.setName("test");
  
          MockMultipartFile file = new MockMultipartFile("file", "contract.pdf", MediaType.APPLICATION_PDF_VALUE, "pdfcontent".getBytes(StandardCharsets.UTF_8));
          MockMultipartFile metadata = new MockMultipartFile("metadata", "", MediaType.APPLICATION_JSON_VALUE, objectMapper.writeValueAsString(metadataDTO).getBytes(StandardCharsets.UTF_8));
          this.mockMvc.perform(fileUpload("/test")
                  .file(file)
                  .file(metadata))
                  .andExpect(status().isNoContent())
                  .andDo(verify()
                          .wiremock(
                                  post(WireMock.urlPathEqualTo("/test"))
                                          .withHeader(HttpHeaders.CONTENT_TYPE, WireMock.containing(MediaType.MULTIPART_FORM_DATA_VALUE))
                                          .withMultipartRequestBody(
                                                  aMultipart()
                                                          .withHeader("Content-Disposition", containing("name=file"))
                                                          .withHeader("Content-Type", WireMock.equalTo(MediaType.APPLICATION_PDF_VALUE))
                                                          .withBody(equalTo("pdfcontent"))
                                          )
                                          .withMultipartRequestBody(
                                                  aMultipart()
                                                          .withHeader("Content-Disposition", containing("name=metadata"))
                                                          .withHeader("Content-Type", WireMock.containing(MediaType.APPLICATION_JSON_VALUE))
                                                          .withBody(WireMock.matchingJsonPath("$[?(@.name == 'test')]"))
                                          )
                          ).stub("testMultipart"))
                  .andDo(document("testMultipart",
                          preprocessRequest(prettyPrint()),
                          requestParts(
                                  partWithName("file").description("The file to upload"),
                                  partWithName("metadata").description("metadata")
                          ),
                          requestPartFields("metadata",
                                  fieldWithPath("name").description("name")
                          )
                          , dslContract()
                  ));
      }
  }
  </code></pre>
  
  <p><strong>Exception</strong></p>
  
  <pre><code>org.junit.ComparisonFailure: [wiremock did not match request] 
  
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at org.springframework.cloud.contract.wiremock.restdocs.WireMockVerifyHelper.configure(WireMockVerifyHelper.java:76)
      at org.springframework.cloud.contract.wiremock.restdocs.ContractResultHandler.handle(ContractResultHandler.java:42)
      at org.springframework.test.web.servlet.MockMvc$1.andDo(MockMvc.java:183)
      at sk.vub.demo.multipart.demorestdocmultipart.DemoRestdocMultipartApplicationTests.contextLoads(DemoRestdocMultipartApplicationTests.java:55)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:73)
      at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:83)
      at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
  </code></pre>