Skip to content

Commit a414d18

Browse files
committed
add a few json serialization tests
1 parent 68f91b2 commit a414d18

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies {
3636

3737
compile "com.squareup.moshi:moshi:1.8.0"
3838
compile "com.squareup.moshi:moshi-kotlin:1.8.0"
39-
compile group: 'org.json', name: 'json', version: '20190722'
39+
compile "org.json:json:20190722"
4040

4141
compile "com.google.http-client:google-http-client:1.31.0"
4242

@@ -53,7 +53,7 @@ dependencies {
5353
}
5454

5555
testCompile "org.junit.jupiter:junit-jupiter-api:$junit_version"
56-
testCompile "org.json:json:20180130"
56+
testCompile "com.google.code.gson:gson:2.8.5"
5757
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
5858
}
5959

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* Spotify Web API - Kotlin Wrapper; MIT License, 2019; Original author: Adam Ratzman */
2+
package com.adamratzman.spotify.utilities
3+
4+
import com.adamratzman.spotify.api
5+
import com.google.gson.Gson
6+
import org.junit.jupiter.api.Assertions.assertTrue
7+
import org.junit.jupiter.api.assertDoesNotThrow
8+
import org.spekframework.spek2.Spek
9+
import org.spekframework.spek2.style.specification.describe
10+
11+
private val gson = Gson()
12+
13+
class JsonTests : Spek({
14+
describe("json serialization tests") {
15+
it("artist serialization") {
16+
assertDoesNotThrow {
17+
assertTrue(gson.toJson(api.artists.getArtist("spotify:artist:5WUlDfRSoLAfcVSX1WnrxN").complete()).isNotEmpty())
18+
}
19+
}
20+
it("track serialization") {
21+
assertDoesNotThrow {
22+
assertTrue(gson.toJson(api.tracks.getTrack("spotify:track:6kcHg7XL6SKyPNd78daRBL").complete()).isNotEmpty())
23+
}
24+
}
25+
it("album serialization") {
26+
assertDoesNotThrow {
27+
println(gson.toJson(api.albums.getAlbum("spotify:album:6ggQNps98xaXMY0OZWevEH").complete()))
28+
assertTrue(gson.toJson(api.albums.getAlbum("spotify:album:6ggQNps98xaXMY0OZWevEH").complete()).isNotEmpty())
29+
}
30+
}
31+
}
32+
})

0 commit comments

Comments
 (0)