title: Springboot test not return expected result
body: <p>all developers, my team is creating a microservice to get the property information using springboot. We have a test suite to mock up the process of making a Http request and verify the response which returns a property information in a stub class. Here is the test:</p>
  
  <pre><code>@WebAppConfiguration
  @RunWith(SpringJUnit4ClassRunner.class)
  @SpringBootTest(classes = Application.class)
  @AutoConfigureMockMvc
  @AutoConfigureRestDocs(outputDir = "build/asciidoc/generated/snippets")
  @ActiveProfiles({ Constants.SPRING_PROFILE_TEST })
  public class SwaggerToMarkupTest {
   @Autowired
   private MockMvc mockMvc;
   @Test
  public void getProperties() throws Exception {
      // given
      String apiOperationName = "getProperty";
  
      MockHttpServletRequestBuilder requestBuilder = get("/api/dimension/properties")
              .accept(APPLICATION_JSON_API_VALUE)
              .header(REQUEST_ID_FIELD_NAME, REQUEST_ID_VALUE)
              .header(CLIENT_ID_FIELD_NAME, CLIENT_ID_VALUE)
              .header(CLIENT_VERSION_FIELD_NAME, CLIENT_VERSION_VALUE)
              .header("Authorization", AUTHORIZATION_VALUE);
  
      // when
      ResultActions actions = mockMvc.perform(requestBuilder);
      actions.andDo(document(apiOperationName, preprocessResponse(prettyPrint())));
  
      // then
      actions.andExpect(status().isOk());
  
      String[] files = new File(ASCIIDOC_SNIPPETS_PARENT_FOLDER + "/" + apiOperationName).list();
      assertThat(files).contains("curl-request.adoc", "http-request.adoc", "http-response.adoc");
  
      String httpResponseDocContent = getHttpResponseDocContent(apiOperationName);
      Assertions.assertThat(httpResponseDocContent).contains("\"type\" : \"properties\"");
  }
  </code></pre>
  
  <p>Here is the request handler:</p>
  
  <pre><code>@GetMapping(value = "/dimension/properties", headers = ACCEPT_APPLICATION_JSON_API_VALUE, produces = APPLICATION_JSON_API_VALUE)
  @Timed(absolute = true, name = "timer.rest.getProperty")
  public DeferredResult&lt;ResponseEntity&lt;GetPropertyResponseDTO&gt;&gt; getProperty() {
     DeferredResult&lt;ResponseEntity&lt;GetPropertyResponseDTO&gt;&gt; deferredResult = new DeferredResult&lt;&gt;();
  
     propertyService.getProperty(uuid)
              .map(properties -&gt; {
                  ResponseEntity&lt;GetPropertyResponseDTO&gt; responseEntity = new ResponseEntity&lt;&gt;(new GetPropertyResponseDTO(properties),
                          HttpStatus.OK);
                  logger.info("Response: " + responseEntity);
                  return responseEntity;
              }).subscribe(deferredResult::setResult, deferredResult::setErrorResult);
  
      return deferredResult;
  }
  </code></pre>
  
  <p>We use Rxjava for the asynchronous call:</p>
  
  <pre><code>public Observable&lt;List&lt;Property&gt;&gt; getProperty(String uuid) {
      return assetsDomainApi.getAssets(uuid, AssetType.PROPERTY)
          .flatMap(assetsResponseVO -&gt; {
              List&lt;Asset&gt; assets = assetMapper.convert(assetsResponseVO);
              assets = propertyInjector.inject(assets);
              Observable&lt;Property&gt; propObsv =
                  Observable.from(assets)
                      .flatMap(assetIdentity -&gt; Observable.just(assetIdentity))
                      .subscribeOn(Schedulers.io())
                      .flatMap(assetIdentity -&gt; {
                          Observable&lt;PropertyDetails&gt; propertyDetailsObs = getPropertyDetails(assetIdentity.getCoreLogicPropertyId());
                          Observable&lt;List&lt;InsuranceProductProperty&gt;&gt; insurancePropertiesObs =
                              getPolicyDetails(assetIdentity);
  
                          Observable&lt;Property&gt; propertyObservable =
                              Observable.zip(propertyDetailsObs, insurancePropertiesObs,
                                  (propDetail, insuranceProperties) -&gt; {
                                      Property property = new Property();
                                      property.setAssetId(assetIdentity.getAssetId());
                                      property.setPropertyDetails(propDetail);
                                      property.setOwnershipType(getOwnershipType(assetIdentity, insuranceProperties.isEmpty()));
                                      if (property.getOwnershipType().equals(DERIVED)) {
                                          property.setSuncorpProducts(new SuncorpProducts&lt;&gt;(insuranceProperties));
                                      }
                                      return property;
                                  });
                          return propertyObservable;
                      });
              return propObsv.toList();
          });
  }
  </code></pre>
  
  <p>Problem is in my test, the status returns 200 but without the body. 
  I am not sure if the problem is in mockMvc or it's the code.</p>
  
  <p>Here are some logs when running this test:</p>
  
  <pre><code>2018-05-10 11:59:57,329 [Test worker] INFO APP=marketplace-dimension-mobile-
  experience-api | ENV=TEST | REQUEST_ID=a | TRACE_ID= | SPAN_ID= | 
  CLIENT_ID=b | CLIENT_VERSION=c | UUID= | PASSIVE=true | CUSTOMER_ENV= | 
  GP_ENV= | a.c.s.i.m.a.r.r.GetPropertiesResource - Request - uuid: 123456
  
  2018-05-10 11:59:57,330 [Test worker] INFO APP=marketplace-dimension-mobile-
  experience-api | ENV=TEST | REQUEST_ID=a | TRACE_ID= | SPAN_ID= | 
  CLIENT_ID=b | CLIENT_VERSION=c | UUID= | PASSIVE=true | CUSTOMER_ENV= | 
  GP_ENV= | a.c.s.i.m.a.r.r.GetPropertiesResource - Response: &lt;200 
  OK,GetPropertyResponseDTO{data=[ResponseData{type=properties, id=2222, 
  attributes=Property{assetid=2222, 
  ownershipType=OwnershipType{value=isDerived},  
  propertyDetails=PropertyDetails{propertyId=3333, occupancyType=House, 
  propertyType=Land, propertySubType=Land: Res House, ...}}]},{}&gt;
  </code></pre>
  
  <p>What I have tried:</p>
  
  <ol>
  <li>Make the same request with same header from postman with the service running, the result has the full body.</li>
  <li>Try to debug from the test, I can't get it debugged properly since quite a few asynchronous calls. </li>
  </ol>
  
  <p>Thanks in Advance </p>