Add converting MusicDirectoryChild list to domain entities list.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
2d12aea79f
commit
645728c0f7
|
@ -48,6 +48,8 @@ fun MusicDirectoryChild.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.
|
|||
}
|
||||
}
|
||||
|
||||
fun List<MusicDirectoryChild>.toDomainEntityList() = this.map { it.toDomainEntity() }
|
||||
|
||||
fun APIMusicDirectory.toDomainEntity(): MusicDirectory = MusicDirectory().apply {
|
||||
name = this@toDomainEntity.name
|
||||
addAll(this@toDomainEntity.childList.map { it.toDomainEntity() })
|
||||
|
|
|
@ -71,7 +71,7 @@ class APIMusicDirectoryConverterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `Should convert MusicDirectoryChild podact entity`() {
|
||||
fun `Should convert MusicDirectoryChild podcast entity`() {
|
||||
val entity = MusicDirectoryChild(id = 584, streamId = 394,
|
||||
artist = "some-artist", publishDate = Calendar.getInstance())
|
||||
|
||||
|
@ -82,4 +82,16 @@ class APIMusicDirectoryConverterTest {
|
|||
artist `should equal to` dateFormat.format(entity.publishDate?.time)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should convert list of MusicDirectoryChild to domain entity list`() {
|
||||
val entitiesList = listOf(MusicDirectoryChild(id = 45), MusicDirectoryChild(id = 34))
|
||||
|
||||
val domainList = entitiesList.toDomainEntityList()
|
||||
|
||||
domainList.size `should equal to` entitiesList.size
|
||||
domainList.forEachIndexed { index, entry ->
|
||||
entry `should equal` entitiesList[index].toDomainEntity()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue