0

i am trying to learn how to write a test using MockServer. In order to test a method, that sends Post Requests. But as i copied the Code from the Documentation into my IDE it can't find the methods: "request()", "exact()", exactly(1)" and "response()". I am guessing those are static imports, and i just can't find the class they belong to. Or are those just method Stubs where i am supposed to pass my own methods?

Here is the Code of the Documentation:

new MockServerClient("localhost", 1080)
.when(
    request()
        .withMethod("POST")
        .withPath("/login")
        .withBody("{username: 'foo', password: 'bar'}")
)
.respond(
    response()
        .withStatusCode(302)
        .withCookie(
            "sessionId", "2By8LOhBmaW5nZXJwcmludCIlMDAzMW"
        )
        .withHeader(
            "Location", "https://www.mock-server.com"
        )
);
Krutoj
  • 23
  • 3
  • `import static org.mockserver.model.HttpRequest.request;` and `import static org.mockserver.model.HttpRequest.response;` should do the trick. – Federico klez Culloca Feb 02 '21 at 08:11
  • Thank you very much. This helps a lot! Unfortunately the static imports for "exact()" and "exactly()". I found the declaration of the static imports in the Documentation when i scrolled further down. And there i found "import static org.mockserver.matchers.Times.exactly" But unfortunately its missing the "exact()" static import. – Krutoj Feb 02 '21 at 08:55

0 Answers0