aloverso
10/29/2018 - 3:13 PM

Spy Rest Template

Spy Rest Template

class SpyRestTemplate: RestOperations {

    lateinit var get_urlCalledWith: String
    lateinit var stubbedGet: String

    val objectMapper = ObjectMapper().registerModule(KotlinModule())

    override fun <T : Any?> getForEntity(url: String, responseType: Class<T>, vararg uriVariables: Any?): ResponseEntity<T> {
        get_urlCalledWith = url

        return ResponseEntity.ok().body(
                objectMapper.readValue(stubbedGet, responseType)
        )
    }
    
    override fun <T : Any?> getForEntity(url: URI, responseType: Class<T>): ResponseEntity<T> {
        TODO("not implemented")
    }

    override fun <T : Any?> postForObject(url: String, request: Any?, responseType: Class<T>, uriVariables: MutableMap<String, *>): T? {
        TODO("not implemented")
    }

    ...
}