Removed toJson() in CallResponse.
This commit is contained in:
parent
353927580d
commit
8060f856ee
9 changed files with 28 additions and 26 deletions
|
@ -32,16 +32,10 @@
|
|||
|
||||
package net.thauvin.erik.bitly
|
||||
|
||||
import org.json.JSONObject
|
||||
|
||||
/**
|
||||
* Provides a data class to hold the JSON response.
|
||||
*/
|
||||
data class CallResponse(var body: String = Constants.EMPTY_JSON, var resultCode: Int = -1) {
|
||||
val isSuccessful: Boolean
|
||||
get() = resultCode in 200..299
|
||||
|
||||
fun toJson(): JSONObject {
|
||||
return JSONObject(body)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ package net.thauvin.erik.bitly
|
|||
|
||||
import net.thauvin.erik.bitly.Utils.Companion.removeHttp
|
||||
import net.thauvin.erik.bitly.Utils.Companion.toEndPoint
|
||||
import org.json.JSONObject
|
||||
import org.junit.Before
|
||||
import java.io.File
|
||||
import java.util.logging.Level
|
||||
|
@ -103,9 +104,12 @@ class BitlyTest {
|
|||
fun `created by`() {
|
||||
assertEquals(
|
||||
"ethauvin",
|
||||
bitly.call("/bitlinks/${shortUrl.removeHttp()}".toEndPoint(), method = Methods.GET)
|
||||
.toJson()
|
||||
.getString("created_by")
|
||||
JSONObject(
|
||||
bitly.call(
|
||||
"/bitlinks/${shortUrl.removeHttp()}".toEndPoint(),
|
||||
method = Methods.GET
|
||||
).body
|
||||
).getString("created_by")
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue