@@ -5,6 +5,8 @@ import com.adamratzman.spotify.api
5
5
import com.adamratzman.spotify.models.Album
6
6
import com.adamratzman.spotify.models.Artist
7
7
import com.adamratzman.spotify.models.ArtistUri
8
+ import com.adamratzman.spotify.models.CursorBasedPagingObject
9
+ import com.adamratzman.spotify.models.PagingObject
8
10
import com.adamratzman.spotify.models.Track
9
11
import kotlinx.serialization.ImplicitReflectionSerializer
10
12
import kotlinx.serialization.UnstableDefault
@@ -43,5 +45,26 @@ class JsonTests : Spek({
43
45
assertEquals(88, artist.popularity)
44
46
assertEquals("artist", artist.type)
45
47
}
48
+ it("paging object deserialization test") {
49
+ val json = """ {"href": "href", "items": [], "limit": 50, "next": "nextHref", "offset": 3, "previous": "previousHref", "total": 5}"""
50
+ val pagingObject = Json .parse(PagingObject .serializer(Artist .serializer()), json)
51
+ assertEquals("href", pagingObject.href)
52
+ assertEquals(emptyList(), pagingObject.items)
53
+ assertEquals(50, pagingObject.limit)
54
+ assertEquals("nextHref", pagingObject.next)
55
+ assertEquals(3, pagingObject.offset)
56
+ assertEquals("previousHref", pagingObject.previous)
57
+ assertEquals(5, pagingObject.total)
58
+ }
59
+ it("cursor based paging object deserialization test") {
60
+ val json = """ {"href": "href", "items": [], "limit": 50, "next": "nextHref", "cursors": {"after": "afterHref"}, "total": 5}"""
61
+ val pagingObject = Json .parse(CursorBasedPagingObject .serializer(Artist .serializer()), json)
62
+ assertEquals("href", pagingObject.href)
63
+ assertEquals(emptyList(), pagingObject.items)
64
+ assertEquals(50, pagingObject.limit)
65
+ assertEquals("nextHref", pagingObject.next)
66
+ assertEquals("afterHref", pagingObject.cursor.after)
67
+ assertEquals(5, pagingObject.total)
68
+ }
46
69
}
47
70
})
0 commit comments