Skip to content

Instantly share code, notes, and snippets.

@jwalgemoed
Last active December 28, 2017 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwalgemoed/5fabeb2a99788228d3ea6dc98b5c20e0 to your computer and use it in GitHub Desktop.
Save jwalgemoed/5fabeb2a99788228d3ea6dc98b5c20e0 to your computer and use it in GitHub Desktop.
data class Contract private constructor(
val request: Request,
val response: Response
) {
class Builder {
var request = Request.Builder()
var response = Response.Builder()
fun build(): Contract {
return Contract(request.build(), response.build())
}
}
}
class Request private constructor(
val path: String,
val method: HttpMethod,
val body: String?,
val headers: HttpHeaders
) {
class Builder {
var path = ""
var method = HttpMethod.GET
var body: String? = null
var expect = Response.Builder()
var headers = HttpHeaders()
fun build(): Request {
return Request(path, method, body?.trimIndent(), headers)
}
}
}
class Response private constructor(
val status: HttpStatus,
val body: String?
) {
class Builder {
var status = HttpStatus.OK
var body: String? = null
fun build(): Response {
return Response(status, body?.trimIndent())
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment