-
-
Save jwalgemoed/5fabeb2a99788228d3ea6dc98b5c20e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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