mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-13 16:07:16 +03:00
Merge pull request #32 from ultrasonic/use-new-get-album
Use new get album
This commit is contained in:
commit
5490a98ecb
@ -0,0 +1,66 @@
|
||||
package org.moire.ultrasonic.api.subsonic
|
||||
|
||||
import org.amshove.kluent.`should contain`
|
||||
import org.amshove.kluent.`should equal to`
|
||||
import org.amshove.kluent.`should equal`
|
||||
import org.junit.Test
|
||||
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
|
||||
|
||||
/**
|
||||
* Integration test for [SubsonicAPIClient] for getAlbum call.
|
||||
*/
|
||||
class SubsonicApiGetAlbumTest : SubsonicAPIClientTest() {
|
||||
@Test
|
||||
fun `Should parse error responce`() {
|
||||
checkErrorCallParsed(mockWebServerRule, {
|
||||
client.api.getAlbum(56L).execute()
|
||||
})
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should add id to request params`() {
|
||||
mockWebServerRule.enqueueResponse("get_album_ok.json")
|
||||
val id = 76L
|
||||
client.api.getAlbum(id).execute()
|
||||
|
||||
val request = mockWebServerRule.mockWebServer.takeRequest()
|
||||
|
||||
request.requestLine `should contain` "id=$id"
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should parse ok response`() {
|
||||
mockWebServerRule.enqueueResponse("get_album_ok.json")
|
||||
|
||||
val response = client.api.getAlbum(512L).execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().album) {
|
||||
id `should equal to` 618L
|
||||
name `should equal to` "Black Ice"
|
||||
artist `should equal to` "AC/DC"
|
||||
artistId `should equal to` 362L
|
||||
coverArt `should equal to` "al-618"
|
||||
songCount `should equal to` 15
|
||||
duration `should equal to` 3331
|
||||
created `should equal` parseDate("2016-10-23T15:31:22.000Z")
|
||||
year `should equal to` 2008
|
||||
genre `should equal to` "Hard Rock"
|
||||
songList.size `should equal to` 15
|
||||
songList[0] `should equal` MusicDirectoryChild(id = 6491L, parent = 6475L, isDir = false,
|
||||
title = "Rock 'n' Roll Train", album = "Black Ice", artist = "AC/DC",
|
||||
track = 1, year = 2008, genre = "Hard Rock", coverArt = "6475", size = 7205451,
|
||||
contentType = "audio/mpeg", suffix = "mp3", duration = 261, bitRate = 219,
|
||||
path = "AC_DC/Black Ice/01 Rock 'n' Roll Train.mp3", isVideo = false,
|
||||
playCount = 0, discNumber = 1, created = parseDate("2016-10-23T15:31:20.000Z"),
|
||||
albumId = 618L, artistId = 362L, type = "music")
|
||||
songList[5] `should equal` MusicDirectoryChild(id = 6492L, parent = 6475L, isDir = false,
|
||||
title = "Smash 'n' Grab", album = "Black Ice", artist = "AC/DC", track = 6,
|
||||
year = 2008, genre = "Hard Rock", coverArt = "6475", size = 6697204,
|
||||
contentType = "audio/mpeg", suffix = "mp3", duration = 246, bitRate = 216,
|
||||
path = "AC_DC/Black Ice/06 Smash 'n' Grab.mp3", isVideo = false, playCount = 0,
|
||||
discNumber = 1, created = parseDate("2016-10-23T15:31:20.000Z"),
|
||||
albumId = 618L, artistId = 362L, type = "music")
|
||||
}
|
||||
}
|
||||
}
|
379
subsonic-api/src/integrationTest/resources/get_album_ok.json
Normal file
379
subsonic-api/src/integrationTest/resources/get_album_ok.json
Normal file
@ -0,0 +1,379 @@
|
||||
{
|
||||
"subsonic-response" : {
|
||||
"status" : "ok",
|
||||
"version" : "1.15.0",
|
||||
"album" : {
|
||||
"id" : "618",
|
||||
"name" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"artistId" : "362",
|
||||
"coverArt" : "al-618",
|
||||
"songCount" : 15,
|
||||
"duration" : 3331,
|
||||
"created" : "2016-10-23T15:31:22.000Z",
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"song" : [ {
|
||||
"id" : "6491",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "Rock 'n' Roll Train",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 1,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 7205451,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 261,
|
||||
"bitRate" : 219,
|
||||
"path" : "AC_DC/Black Ice/01 Rock 'n' Roll Train.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:20.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6500",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "Skies on Fire",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 2,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 5634607,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 214,
|
||||
"bitRate" : 209,
|
||||
"path" : "AC_DC/Black Ice/02 Skies on Fire.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:22.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6496",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "Big Jack",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 3,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 6274247,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 237,
|
||||
"bitRate" : 211,
|
||||
"path" : "AC_DC/Black Ice/03 Big Jack.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:22.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6488",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "Anything Goes",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 4,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 5763074,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 202,
|
||||
"bitRate" : 227,
|
||||
"path" : "AC_DC/Black Ice/04 Anything Goes.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:20.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6501",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "War Machine",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 5,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 4962101,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 189,
|
||||
"bitRate" : 208,
|
||||
"path" : "AC_DC/Black Ice/05 War Machine.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:20.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6492",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "Smash 'n' Grab",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 6,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 6697204,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 246,
|
||||
"bitRate" : 216,
|
||||
"path" : "AC_DC/Black Ice/06 Smash 'n' Grab.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:20.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6499",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "Spoilin' for a Fight",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 7,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 5481070,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 197,
|
||||
"bitRate" : 222,
|
||||
"path" : "AC_DC/Black Ice/07 Spoilin' for a Fight.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:21.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6487",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "Wheels",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 8,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 5837241,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 208,
|
||||
"bitRate" : 223,
|
||||
"path" : "AC_DC/Black Ice/08 Wheels.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:22.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6495",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "Decibel",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 9,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 5251982,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 213,
|
||||
"bitRate" : 195,
|
||||
"path" : "AC_DC/Black Ice/09 Decibel.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:19.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6494",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "Stormy May Day",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 10,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 5105168,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 190,
|
||||
"bitRate" : 214,
|
||||
"path" : "AC_DC/Black Ice/10 Stormy May Day.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:20.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6493",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "She Likes Rock 'n' Roll",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 11,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 6135766,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 232,
|
||||
"bitRate" : 210,
|
||||
"path" : "AC_DC/Black Ice/11 She Likes Rock 'n' Roll.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:22.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6497",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "Money Made",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 12,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 6816386,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 255,
|
||||
"bitRate" : 213,
|
||||
"path" : "AC_DC/Black Ice/12 Money Made.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:21.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6489",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "Rock 'n' Roll Dream",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 13,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 7486707,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 280,
|
||||
"bitRate" : 212,
|
||||
"path" : "AC_DC/Black Ice/13 Rock 'n' Roll Dream.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:20.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6498",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "Rocking All the Way",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 14,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 4927026,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 202,
|
||||
"bitRate" : 194,
|
||||
"path" : "AC_DC/Black Ice/14 Rocking All the Way.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:22.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "6490",
|
||||
"parent" : "6475",
|
||||
"isDir" : false,
|
||||
"title" : "Black Ice",
|
||||
"album" : "Black Ice",
|
||||
"artist" : "AC/DC",
|
||||
"track" : 15,
|
||||
"year" : 2008,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "6475",
|
||||
"size" : 5192799,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 205,
|
||||
"bitRate" : 202,
|
||||
"path" : "AC_DC/Black Ice/15 Black Ice.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T15:31:22.000Z",
|
||||
"albumId" : "618",
|
||||
"artistId" : "362",
|
||||
"type" : "music"
|
||||
} ]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package org.moire.ultrasonic.api.subsonic
|
||||
|
||||
import org.moire.ultrasonic.api.subsonic.response.GetAlbumResponse
|
||||
import org.moire.ultrasonic.api.subsonic.response.GetArtistResponse
|
||||
import org.moire.ultrasonic.api.subsonic.response.GetArtistsResponse
|
||||
import org.moire.ultrasonic.api.subsonic.response.GetIndexesResponse
|
||||
@ -48,4 +49,7 @@ interface SubsonicAPIDefinition {
|
||||
|
||||
@GET("getArtist.view")
|
||||
fun getArtist(@Query("id") id: Long): Call<GetArtistResponse>
|
||||
|
||||
@GET("getAlbum.view")
|
||||
fun getAlbum(@Query("id") id: Long): Call<GetAlbumResponse>
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.moire.ultrasonic.api.subsonic.models
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import java.util.Calendar
|
||||
|
||||
data class Album(
|
||||
@ -12,4 +13,5 @@ data class Album(
|
||||
val duration: Int = 0,
|
||||
val created: Calendar? = null,
|
||||
val year: Int = 0,
|
||||
val genre: String = "")
|
||||
val genre: String = "",
|
||||
@JsonProperty("song") val songList: List<MusicDirectoryChild> = emptyList())
|
||||
|
@ -0,0 +1,10 @@
|
||||
package org.moire.ultrasonic.api.subsonic.response
|
||||
|
||||
import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
|
||||
import org.moire.ultrasonic.api.subsonic.SubsonicError
|
||||
import org.moire.ultrasonic.api.subsonic.models.Album
|
||||
|
||||
class GetAlbumResponse(status: Status,
|
||||
version: SubsonicAPIVersions,
|
||||
error: SubsonicError?,
|
||||
val album: Album = Album()) : SubsonicResponse(status, version, error)
|
@ -56,6 +56,7 @@ import org.apache.http.protocol.ExecutionContext;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
import org.moire.ultrasonic.R;
|
||||
import org.moire.ultrasonic.api.subsonic.SubsonicAPIClient;
|
||||
import org.moire.ultrasonic.api.subsonic.response.GetAlbumResponse;
|
||||
import org.moire.ultrasonic.api.subsonic.response.GetArtistResponse;
|
||||
import org.moire.ultrasonic.api.subsonic.response.GetArtistsResponse;
|
||||
import org.moire.ultrasonic.api.subsonic.response.GetIndexesResponse;
|
||||
@ -388,21 +389,23 @@ public class RESTMusicService implements MusicService
|
||||
return APIConverter.toMusicDirectoryDomainEntity(response.body().getArtist());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MusicDirectory getAlbum(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception
|
||||
{
|
||||
checkServerVersion(context, "1.8", "Album by ID3 tag not supported.");
|
||||
@Override
|
||||
public MusicDirectory getAlbum(String id,
|
||||
String name,
|
||||
boolean refresh,
|
||||
Context context,
|
||||
ProgressListener progressListener) throws Exception {
|
||||
if (id == null) {
|
||||
throw new IllegalArgumentException("Id argument is null!");
|
||||
}
|
||||
|
||||
Reader reader = getReader(context, progressListener, "getAlbum", null, "id", id);
|
||||
try
|
||||
{
|
||||
return new MusicDirectoryParser(context).parse(name, reader, progressListener, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Util.close(reader);
|
||||
}
|
||||
}
|
||||
updateProgressListener(progressListener, R.string.parser_reading);
|
||||
Response<GetAlbumResponse> response = subsonicAPIClient.getApi()
|
||||
.getAlbum(Long.valueOf(id)).execute();
|
||||
checkResponseSuccessful(response);
|
||||
|
||||
return APIConverter.toMusicDirectoryDomainEntity(response.body().getAlbum());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchResult search(SearchCriteria criteria, Context context, ProgressListener progressListener) throws Exception
|
||||
|
@ -49,6 +49,10 @@ fun Album.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry().apply
|
||||
genre = this@toDomainEntity.genre
|
||||
}
|
||||
|
||||
fun Album.toMusicDirectoryDomainEntity(): MusicDirectory = MusicDirectory().apply {
|
||||
addAll(this@toMusicDirectoryDomainEntity.songList.map { it.toDomainEntity() })
|
||||
}
|
||||
|
||||
fun MusicDirectoryChild.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry().apply {
|
||||
id = this@toDomainEntity.id.toString()
|
||||
parent = this@toDomainEntity.parent.toString()
|
||||
@ -65,13 +69,13 @@ fun MusicDirectoryChild.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.
|
||||
suffix = this@toDomainEntity.suffix
|
||||
transcodedContentType = this@toDomainEntity.transcodedContentType
|
||||
transcodedSuffix = this@toDomainEntity.transcodedSuffix
|
||||
coverArt = this@toDomainEntity.coverArt.toString()
|
||||
coverArt = this@toDomainEntity.coverArt
|
||||
size = this@toDomainEntity.size
|
||||
duration = this@toDomainEntity.duration
|
||||
bitRate = this@toDomainEntity.bitRate
|
||||
path = this@toDomainEntity.path
|
||||
setIsVideo(this@toDomainEntity.isVideo)
|
||||
setCreated(this@toDomainEntity.created?.time)
|
||||
created = this@toDomainEntity.created?.time
|
||||
starred = this@toDomainEntity.starred != null
|
||||
discNumber = this@toDomainEntity.discNumber
|
||||
type = this@toDomainEntity.type
|
||||
|
@ -176,6 +176,22 @@ class APIConverterTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should convert to MusicDirectory domain entity`() {
|
||||
val entity = Album(id = 101L, name = "some-album", artist = "some-artist", artistId = 54L,
|
||||
coverArt = "some-id", songCount = 10, duration = 456,
|
||||
created = Calendar.getInstance(), year = 2022, genre = "Hard Rock",
|
||||
songList = listOf(MusicDirectoryChild()))
|
||||
|
||||
val convertedEntity = entity.toMusicDirectoryDomainEntity()
|
||||
|
||||
with(convertedEntity) {
|
||||
name `should equal` null
|
||||
children.size `should equal to` entity.songList.size
|
||||
children[0] `should equal` entity.songList[0].toDomainEntity()
|
||||
}
|
||||
}
|
||||
|
||||
private fun createMusicFolder(id: Long = 0, name: String = ""): MusicFolder =
|
||||
MusicFolder(id, name)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user