Skip to content

Instantly share code, notes, and snippets.

@burcuakkayaa
Last active December 14, 2023 10:27
Show Gist options
  • Save burcuakkayaa/c8366b425a5d8b6efd8bea353ddffccb to your computer and use it in GitHub Desktop.
Save burcuakkayaa/c8366b425a5d8b6efd8bea353ddffccb to your computer and use it in GitHub Desktop.
package api.core.services.mock
import com.github.tomakehurst.wiremock.client.WireMock
import com.github.tomakehurst.wiremock.stubbing.StubMapping
import java.util.*
class UsersMockApiController {
companion object {
fun postNewUserMapping(
requestBody: String,
statusCode: Int,
specificStubMockId: UUID,
responseBody: String
): StubMapping {
return WireMock.stubFor(
WireMock.post(WireMock.urlEqualTo("/users"))
.withId(specificStubMockId)
.withRequestBody(WireMock.equalToJson(requestBody))
.willReturn(
WireMock.aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/json; charset=UTF-8")
.withBody(responseBody)
)
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment