add unit test for token type serialization

This commit is contained in:
Jannik 2022-07-16 15:08:13 +02:00
parent 3cadaa5c7a
commit 127bd030b9
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
3 changed files with 33 additions and 17 deletions

View File

@ -1,17 +0,0 @@
package org.mosad.teapod
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

View File

@ -0,0 +1,24 @@
package org.mosad.teapod.parser.crunchyroll
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import org.junit.Assert
import org.junit.Test
class DataTypesTest {
@Test
fun testTokenType() {
val testToken = javaClass.getResource("/token.json")!!.readText()
val token: Token = Json.decodeFromString(testToken)
Assert.assertEquals("TestAccessToken-1_TestAccessToken", token.accessToken)
Assert.assertEquals("00000000-0000-0000-0000-000000000000", token.refreshToken)
Assert.assertEquals(300, token.expiresIn)
Assert.assertEquals("Bearer", token.tokenType)
Assert.assertEquals("account content offline_access reviews talkbox", token.scope)
Assert.assertEquals("DE", token.country)
Assert.assertEquals("00000000-0000-0000-0000-000000000000", token.accountId)
}
}

View File

@ -0,0 +1,9 @@
{
"access_token":"TestAccessToken-1_TestAccessToken",
"refresh_token":"00000000-0000-0000-0000-000000000000",
"expires_in":300,
"token_type":"Bearer",
"scope":"account content offline_access reviews talkbox",
"country":"DE",
"account_id":"00000000-0000-0000-0000-000000000000"
}