Change album ids type to String.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
a694f895e9
commit
f2d838cb1c
|
@ -30,12 +30,12 @@ class SubsonicApiGetAlbumList2Test : SubsonicAPIClientTest() {
|
||||||
assertResponseSuccessful(response)
|
assertResponseSuccessful(response)
|
||||||
with(response.body().albumList) {
|
with(response.body().albumList) {
|
||||||
this.size `should equal to` 2
|
this.size `should equal to` 2
|
||||||
this[0] `should equal` Album(id = 962, name = "Fury", artist = "Sick Puppies",
|
this[0] `should equal` Album(id = "962", name = "Fury", artist = "Sick Puppies",
|
||||||
artistId = 473, coverArt = "al-962", songCount = 13, duration = 2591,
|
artistId = "473", coverArt = "al-962", songCount = 13, duration = 2591,
|
||||||
created = parseDate("2017-09-02T17:34:51.000Z"), year = 2016,
|
created = parseDate("2017-09-02T17:34:51.000Z"), year = 2016,
|
||||||
genre = "Alternative Rock")
|
genre = "Alternative Rock")
|
||||||
this[1] `should equal` Album(id = 961, name = "Endless Forms Most Beautiful",
|
this[1] `should equal` Album(id = "961", name = "Endless Forms Most Beautiful",
|
||||||
artist = "Nightwish", artistId = 559, coverArt = "al-961", songCount = 22,
|
artist = "Nightwish", artistId = "559", coverArt = "al-961", songCount = 22,
|
||||||
duration = 9469, created = parseDate("2017-09-02T16:22:47.000Z"),
|
duration = 9469, created = parseDate("2017-09-02T16:22:47.000Z"),
|
||||||
year = 2015, genre = "Symphonic Metal")
|
year = 2015, genre = "Symphonic Metal")
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,10 +39,10 @@ class SubsonicApiGetAlbumTest : SubsonicAPIClientTest() {
|
||||||
|
|
||||||
assertResponseSuccessful(response)
|
assertResponseSuccessful(response)
|
||||||
with(response.body().album) {
|
with(response.body().album) {
|
||||||
id `should equal to` 618L
|
id `should equal to` "618"
|
||||||
name `should equal to` "Black Ice"
|
name `should equal to` "Black Ice"
|
||||||
artist `should equal to` "AC/DC"
|
artist `should equal to` "AC/DC"
|
||||||
artistId `should equal to` 362L
|
artistId `should equal to` "362"
|
||||||
coverArt `should equal to` "al-618"
|
coverArt `should equal to` "al-618"
|
||||||
songCount `should equal to` 15
|
songCount `should equal to` 15
|
||||||
duration `should equal to` 3331
|
duration `should equal to` 3331
|
||||||
|
|
|
@ -44,12 +44,12 @@ class SubsonicApiGetArtistTest : SubsonicAPIClientTest() {
|
||||||
coverArt `should equal to` "ar-362"
|
coverArt `should equal to` "ar-362"
|
||||||
albumCount `should equal to` 2
|
albumCount `should equal to` 2
|
||||||
albumsList.size `should equal to` 2
|
albumsList.size `should equal to` 2
|
||||||
albumsList[0] `should equal` Album(id = 618L, name = "Black Ice", artist = "AC/DC",
|
albumsList[0] `should equal` Album(id = "618", name = "Black Ice", artist = "AC/DC",
|
||||||
artistId = 362L, coverArt = "al-618", songCount = 15, duration = 3331,
|
artistId = "362", coverArt = "al-618", songCount = 15, duration = 3331,
|
||||||
created = parseDate("2016-10-23T15:31:22.000Z"),
|
created = parseDate("2016-10-23T15:31:22.000Z"),
|
||||||
year = 2008, genre = "Hard Rock")
|
year = 2008, genre = "Hard Rock")
|
||||||
albumsList[1] `should equal` Album(id = 617L, name = "Rock or Bust", artist = "AC/DC",
|
albumsList[1] `should equal` Album(id = "617", name = "Rock or Bust", artist = "AC/DC",
|
||||||
artistId = 362L, coverArt = "al-617", songCount = 11, duration = 2095,
|
artistId = "362", coverArt = "al-617", songCount = 11, duration = 2095,
|
||||||
created = parseDate("2016-10-23T15:31:23.000Z"),
|
created = parseDate("2016-10-23T15:31:23.000Z"),
|
||||||
year = 2014, genre = "Hard Rock")
|
year = 2014, genre = "Hard Rock")
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ class SubsonicApiSearchThreeTest : SubsonicAPIClientTest() {
|
||||||
artistList[0] `should equal` Artist(id = "505", name = "The Prodigy", coverArt = "ar-505",
|
artistList[0] `should equal` Artist(id = "505", name = "The Prodigy", coverArt = "ar-505",
|
||||||
albumCount = 5)
|
albumCount = 5)
|
||||||
albumList.size `should equal to` 1
|
albumList.size `should equal to` 1
|
||||||
albumList[0] `should equal` Album(id = 855, name = "Always Outnumbered, Never Outgunned",
|
albumList[0] `should equal` Album(id = "855", name = "Always Outnumbered, Never Outgunned",
|
||||||
artist = "The Prodigy", artistId = 505, coverArt = "al-855", songCount = 12,
|
artist = "The Prodigy", artistId = "505", coverArt = "al-855", songCount = 12,
|
||||||
duration = 3313, created = parseDate("2016-10-23T20:57:27.000Z"),
|
duration = 3313, created = parseDate("2016-10-23T20:57:27.000Z"),
|
||||||
year = 2004, genre = "Electronic")
|
year = 2004, genre = "Electronic")
|
||||||
songList.size `should equal to` 1
|
songList.size `should equal to` 1
|
||||||
|
|
|
@ -4,11 +4,11 @@ import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
|
||||||
data class Album(
|
data class Album(
|
||||||
val id: Long = -1L,
|
val id: String = "",
|
||||||
val name: String = "",
|
val name: String = "",
|
||||||
val coverArt: String = "",
|
val coverArt: String = "",
|
||||||
val artist: String = "",
|
val artist: String = "",
|
||||||
val artistId: Long = -1L,
|
val artistId: String = "",
|
||||||
val songCount: Int = 0,
|
val songCount: Int = 0,
|
||||||
val duration: Int = 0,
|
val duration: Int = 0,
|
||||||
val created: Calendar? = null,
|
val created: Calendar? = null,
|
||||||
|
|
|
@ -7,12 +7,12 @@ import org.moire.ultrasonic.api.subsonic.models.Album
|
||||||
import org.moire.ultrasonic.domain.MusicDirectory
|
import org.moire.ultrasonic.domain.MusicDirectory
|
||||||
|
|
||||||
fun Album.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry().apply {
|
fun Album.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry().apply {
|
||||||
id = this@toDomainEntity.id.toString()
|
id = this@toDomainEntity.id
|
||||||
setIsDirectory(true)
|
setIsDirectory(true)
|
||||||
title = this@toDomainEntity.name
|
title = this@toDomainEntity.name
|
||||||
coverArt = this@toDomainEntity.coverArt
|
coverArt = this@toDomainEntity.coverArt
|
||||||
artist = this@toDomainEntity.artist
|
artist = this@toDomainEntity.artist
|
||||||
artistId = this@toDomainEntity.artistId.toString()
|
artistId = this@toDomainEntity.artistId
|
||||||
songCount = this@toDomainEntity.songCount.toLong()
|
songCount = this@toDomainEntity.songCount.toLong()
|
||||||
duration = this@toDomainEntity.duration
|
duration = this@toDomainEntity.duration
|
||||||
created = this@toDomainEntity.created?.time
|
created = this@toDomainEntity.created?.time
|
||||||
|
|
|
@ -15,19 +15,19 @@ import java.util.Calendar
|
||||||
class APIAlbumConverterTest {
|
class APIAlbumConverterTest {
|
||||||
@Test
|
@Test
|
||||||
fun `Should convert Album to domain entity`() {
|
fun `Should convert Album to domain entity`() {
|
||||||
val entity = Album(id = 387L, name = "some-name", coverArt = "asdas", artist = "some-artist",
|
val entity = Album(id = "387", name = "some-name", coverArt = "asdas", artist = "some-artist",
|
||||||
artistId = 390L, songCount = 12, duration = 841, created = Calendar.getInstance(),
|
artistId = "390", songCount = 12, duration = 841, created = Calendar.getInstance(),
|
||||||
year = 2017, genre = "some-genre")
|
year = 2017, genre = "some-genre")
|
||||||
|
|
||||||
val convertedEntity = entity.toDomainEntity()
|
val convertedEntity = entity.toDomainEntity()
|
||||||
|
|
||||||
with(convertedEntity) {
|
with(convertedEntity) {
|
||||||
id `should equal to` entity.id.toString()
|
id `should equal to` entity.id
|
||||||
title `should equal to` entity.name
|
title `should equal to` entity.name
|
||||||
isDirectory `should equal to` true
|
isDirectory `should equal to` true
|
||||||
coverArt `should equal to` entity.coverArt
|
coverArt `should equal to` entity.coverArt
|
||||||
artist `should equal to` entity.artist
|
artist `should equal to` entity.artist
|
||||||
artistId `should equal to` entity.artistId.toString()
|
artistId `should equal to` entity.artistId
|
||||||
songCount `should equal to` entity.songCount.toLong()
|
songCount `should equal to` entity.songCount.toLong()
|
||||||
duration `should equal to` entity.duration
|
duration `should equal to` entity.duration
|
||||||
created `should equal` entity.created?.time
|
created `should equal` entity.created?.time
|
||||||
|
@ -38,7 +38,7 @@ class APIAlbumConverterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Should convert to MusicDirectory domain entity`() {
|
fun `Should convert to MusicDirectory domain entity`() {
|
||||||
val entity = Album(id = 101L, name = "some-album", artist = "some-artist", artistId = 54L,
|
val entity = Album(id = "101", name = "some-album", artist = "some-artist", artistId = "54",
|
||||||
coverArt = "some-id", songCount = 10, duration = 456,
|
coverArt = "some-id", songCount = 10, duration = 456,
|
||||||
created = Calendar.getInstance(), year = 2022, genre = "Hard Rock",
|
created = Calendar.getInstance(), year = 2022, genre = "Hard Rock",
|
||||||
songList = listOf(MusicDirectoryChild()))
|
songList = listOf(MusicDirectoryChild()))
|
||||||
|
@ -54,7 +54,7 @@ class APIAlbumConverterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Should convert list of Album entities to domain list entities`() {
|
fun `Should convert list of Album entities to domain list entities`() {
|
||||||
val entityList = listOf(Album(id = 455), Album(id = 1), Album(id = 1000))
|
val entityList = listOf(Album(id = "455"), Album(id = "1"), Album(id = "1000"))
|
||||||
|
|
||||||
val convertedList = entityList.toDomainEntityList()
|
val convertedList = entityList.toDomainEntityList()
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.moire.ultrasonic.api.subsonic.models.Artist
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit test for extension functions in [APIArtistConverter.kt] file.
|
* Unit test for extension functions in APIArtistConverter.kt file.
|
||||||
*/
|
*/
|
||||||
class APIArtistConverterTest {
|
class APIArtistConverterTest {
|
||||||
@Test
|
@Test
|
||||||
|
@ -20,7 +20,7 @@ class APIArtistConverterTest {
|
||||||
val convertedEntity = entity.toDomainEntity()
|
val convertedEntity = entity.toDomainEntity()
|
||||||
|
|
||||||
with(convertedEntity) {
|
with(convertedEntity) {
|
||||||
id `should equal to` entity.id.toString()
|
id `should equal to` entity.id
|
||||||
name `should equal to` entity.name
|
name `should equal to` entity.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ class APIArtistConverterTest {
|
||||||
@Test
|
@Test
|
||||||
fun `Should convert Artist entity to domain MusicDirectory entity`() {
|
fun `Should convert Artist entity to domain MusicDirectory entity`() {
|
||||||
val entity = Artist(id = "101", name = "artist-name", coverArt = "some-art", albumCount = 10,
|
val entity = Artist(id = "101", name = "artist-name", coverArt = "some-art", albumCount = 10,
|
||||||
albumsList = listOf(Album(id = 562L, name = "some-name", coverArt = "zzz",
|
albumsList = listOf(Album(id = "562", name = "some-name", coverArt = "zzz",
|
||||||
artist = "artist-name", artistId = 256L, songCount = 10, duration = 345,
|
artist = "artist-name", artistId = "256", songCount = 10, duration = 345,
|
||||||
created = Calendar.getInstance(), year = 2011, genre = "Math Rock")))
|
created = Calendar.getInstance(), year = 2011, genre = "Math Rock")))
|
||||||
|
|
||||||
val convertedEntity = entity.toMusicDirectoryDomainEntity()
|
val convertedEntity = entity.toMusicDirectoryDomainEntity()
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.moire.ultrasonic.api.subsonic.models.SearchThreeResult
|
||||||
import org.moire.ultrasonic.api.subsonic.models.SearchTwoResult
|
import org.moire.ultrasonic.api.subsonic.models.SearchTwoResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit test for extension function in [APISearchConverter.kt] file.
|
* Unit test for extension function in APISearchConverter.kt file.
|
||||||
*/
|
*/
|
||||||
class APISearchConverterTest {
|
class APISearchConverterTest {
|
||||||
@Test
|
@Test
|
||||||
|
@ -61,7 +61,7 @@ class APISearchConverterTest {
|
||||||
fun `Should convert SearchThreeResult to domain entity`() {
|
fun `Should convert SearchThreeResult to domain entity`() {
|
||||||
val entity = SearchThreeResult(
|
val entity = SearchThreeResult(
|
||||||
artistList = listOf(Artist(id = "612", name = "artist1")),
|
artistList = listOf(Artist(id = "612", name = "artist1")),
|
||||||
albumList = listOf(Album(id = 221, name = "album1")),
|
albumList = listOf(Album(id = "221", name = "album1")),
|
||||||
songList = listOf(MusicDirectoryChild(id = 7123, title = "song1"))
|
songList = listOf(MusicDirectoryChild(id = 7123, title = "song1"))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue