Skip to content

Instantly share code, notes, and snippets.

@tugceaktepe
Created June 15, 2023 22:34
Show Gist options
  • Save tugceaktepe/38ac1698aac4503edd2d3601e7050e63 to your computer and use it in GitHub Desktop.
Save tugceaktepe/38ac1698aac4503edd2d3601e7050e63 to your computer and use it in GitHub Desktop.
throttleBody example
internal inner class RequestDispatcher : Dispatcher() {
override fun dispatch(request: RecordedRequest): MockResponse {
return when (request.path) {
"/movie/top_rated?api_key=${API_KEY}&language=en-US&page=1" ->
MockResponse().setResponseCode(200)
.setBody(FileReader.readStringFromFile("success_response.json"))
.throttleBody(1024, 200L, TimeUnit.MILLISECONDS)
else -> MockResponse().setResponseCode(400)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment