@file:Suppress("IllegalIdentifier") package org.moire.ultrasonic.domain import java.util.Calendar import org.amshove.kluent.`should be equal to` import org.junit.Test import org.moire.ultrasonic.api.subsonic.models.Bookmark import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild /** * Unit test for function that converts [Bookmark] api entity to domain. */ class APIBookmarkConverterTest { @Test fun `Should convert to domain entity`() { val entity = Bookmark( 412313L, "Awesemo", "Nice", Calendar.getInstance(), Calendar.getInstance(), MusicDirectoryChild(id = "12333") ) val domainEntity = entity.toDomainEntity() with(domainEntity) { position `should be equal to` entity.position.toInt() username `should be equal to` entity.username comment `should be equal to` entity.comment created `should be equal to` entity.created?.time changed `should be equal to` entity.changed?.time entry `should be equal to` entity.entry.toTrackEntity() } } @Test fun `Should convert list of entities to domain entities`() { val entitiesList = listOf(Bookmark(443L), Bookmark(444L)) val domainEntitiesList = entitiesList.toDomainEntitiesList() domainEntitiesList.size `should be equal to` entitiesList.size domainEntitiesList.forEachIndexed({ index, bookmark -> bookmark `should be equal to` entitiesList[index].toDomainEntity() }) } }