title: Unable to use mock HTTP/HTTPS get post request for json/xml response
body: <p>Here is my code for junit.</p>
  
  <p>I'm following this documentation  for mock-server <a href="http://www.mock-server.com/" rel="nofollow noreferrer">http://www.mock-server.com/</a></p>
  
  <pre><code>mockServerClient=new MockServerClient("127.0.0.1", 8080)
      .when(
              request()
                      .withMethod("POST")
                      .withPath("/login")
                      .withQueryStringParameters(
                              new Parameter("returnUrl", "/account")
                      )
                      .withCookies(
                              new Cookie("sessionId", "2By8LOhBmaW5nZXJwcmludCIlMDAzMW")
                      )
                      .withBody(exact("{username: 'foo', password: 'bar'}")),
              exactly(1)
      )
      .respond(
              response()
                      .withStatusCode(401)
                      .withHeaders(
                              new Header("Content-Type", "application/json; charset=utf-8"),
                              new Header("Cache-Control", "public, max-age=86400")
                      )
                      .withBody("{ message: 'incorrect username and password combination' }")
                      .withDelay(new Delay(TimeUnit.SECONDS, 1))
      );
  </code></pre>
  
  <p>The problem is request, response, exactly, exact, Header are not getting resolved in editor.
  Some additional imports must be required but I couldn't find any working example/alternate to it.</p>
  
  <p>All I need is simply mocking a server url request and responses to be used in Junits.
  As an alternative to mock server I also tried Mockwebserver-<a href="https://github.com/square/okhttp/tree/master/mockwebserver" rel="nofollow noreferrer">https://github.com/square/okhttp/tree/master/mockwebserver</a></p>
  
  <p>but it too has many limitations like I'm unable to do post using mockwebserver.
  Also checking other options suggested here <a href="https://stackoverflow.com/questions/393099/mocking-http-server">https://stackoverflow.com/questions/393099/mocking-http-server</a>.
  If anyone knows a working solution please help me.
  Thanks in advance</p>