Fix unit tests.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2018-02-24 22:19:34 +01:00
parent a11037ecf1
commit 182eb7ec3b
4 changed files with 34 additions and 31 deletions

View File

@ -21,6 +21,8 @@ class MusicDirectory {
fun findChild(id: String): Entry? = children.lastOrNull { it.id == id } fun findChild(id: String): Entry? = children.lastOrNull { it.id == id }
fun getAllChild(): List<Entry> = children.toList()
@JvmOverloads @JvmOverloads
fun getChildren( fun getChildren(
includeDirs: Boolean = true, includeDirs: Boolean = true,

View File

@ -2,7 +2,6 @@
package org.moire.ultrasonic.domain package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal` import org.amshove.kluent.`should equal`
import org.junit.Test import org.junit.Test
import org.moire.ultrasonic.api.subsonic.models.Album import org.moire.ultrasonic.api.subsonic.models.Album
@ -36,8 +35,9 @@ class APIArtistConverterTest {
val convertedEntity = entity.toMusicDirectoryDomainEntity() val convertedEntity = entity.toMusicDirectoryDomainEntity()
with(convertedEntity) { with(convertedEntity) {
name `should equal to` entity.name name `should equal` entity.name
children `should equal` entity.albumsList.map { it.toDomainEntity() }.toMutableList() getAllChild() `should equal` entity.albumsList
.map { it.toDomainEntity() }.toMutableList()
} }
} }
} }

View File

@ -22,9 +22,10 @@ class APIMusicDirectoryConverterTest {
val convertedEntity = entity.toDomainEntity() val convertedEntity = entity.toDomainEntity()
with(convertedEntity) { with(convertedEntity) {
name `should equal to` entity.name name `should equal` entity.name
children.size `should equal to` entity.childList.size getAllChild().size `should equal to` entity.childList.size
children `should equal` entity.childList.map { it.toDomainEntity() }.toMutableList() getAllChild() `should equal` entity.childList
.map { it.toDomainEntity() }.toMutableList()
} }
} }
@ -43,31 +44,31 @@ class APIMusicDirectoryConverterTest {
val convertedEntity = entity.toDomainEntity() val convertedEntity = entity.toDomainEntity()
with(convertedEntity) { with(convertedEntity) {
id `should equal to` entity.id id `should equal` entity.id
parent `should equal to` entity.parent parent `should equal` entity.parent
isDirectory `should equal to` entity.isDir isDirectory `should equal to` entity.isDir
title `should equal` entity.title title `should equal` entity.title
album `should equal` entity.album album `should equal` entity.album
albumId `should equal to` entity.albumId albumId `should equal` entity.albumId
artist `should equal to` entity.artist artist `should equal` entity.artist
artistId `should equal to` entity.artistId artistId `should equal` entity.artistId
track `should equal to` entity.track track `should equal` entity.track
year `should equal to` entity.year!! year `should equal` entity.year!!
genre `should equal to` entity.genre genre `should equal` entity.genre
contentType `should equal to` entity.contentType contentType `should equal` entity.contentType
suffix `should equal to` entity.suffix suffix `should equal` entity.suffix
transcodedContentType `should equal to` entity.transcodedContentType transcodedContentType `should equal` entity.transcodedContentType
transcodedSuffix `should equal to` entity.transcodedSuffix transcodedSuffix `should equal` entity.transcodedSuffix
coverArt `should equal to` entity.coverArt coverArt `should equal` entity.coverArt
size `should equal to` entity.size size `should equal` entity.size
duration `should equal to` entity.duration duration `should equal` entity.duration
bitRate `should equal to` entity.bitRate bitRate `should equal` entity.bitRate
path `should equal to` entity.path path `should equal` entity.path
isVideo `should equal to` entity.isVideo isVideo `should equal to` entity.isVideo
created `should equal` entity.created?.time created `should equal` entity.created?.time
starred `should equal to` (entity.starred != null) starred `should equal to` (entity.starred != null)
discNumber `should equal to` entity.discNumber discNumber `should equal` entity.discNumber
type `should equal to` entity.type type `should equal` entity.type
} }
} }
@ -79,8 +80,8 @@ class APIMusicDirectoryConverterTest {
val convertedEntity = entity.toDomainEntity() val convertedEntity = entity.toDomainEntity()
with(convertedEntity) { with(convertedEntity) {
id `should equal to` entity.streamId id `should equal` entity.streamId
artist `should equal to` dateFormat.format(entity.publishDate?.time) artist `should equal` dateFormat.format(entity.publishDate?.time)
} }
} }

View File

@ -23,10 +23,10 @@ class APIPlaylistConverterTest {
val convertedEntity = entity.toMusicDirectoryDomainEntity() val convertedEntity = entity.toMusicDirectoryDomainEntity()
with(convertedEntity) { with(convertedEntity) {
name `should equal to` entity.name name `should equal` entity.name
children.size `should equal to` entity.entriesList.size getAllChild().size `should equal to` entity.entriesList.size
children[0] `should equal` entity.entriesList[0].toDomainEntity() getAllChild()[0] `should equal` entity.entriesList[0].toDomainEntity()
children[1] `should equal` entity.entriesList[1].toDomainEntity() getAllChild()[1] `should equal` entity.entriesList[1].toDomainEntity()
} }
} }