mardi 2 février 2021

Are the Methods described in the Documentation of MockServer static imports or am i supposed to pass my own methods?

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"
        )
);

Aucun commentaire:

Enregistrer un commentaire