package io.delphiplatform.api.v3.rdb.service import io.delphiplatform.api.v3.rdb.entity.shazam.ShazamArtistIsrcEntity import io.delphiplatform.api.v3.rdb.repository.ShazamArtistIsrcRepository import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.kotlin.mock import org.mockito.kotlin.whenever internal class ShazamArtistServiceTest { private val repository: ShazamArtistIsrcRepository = mock() private val service: ShazamArtistService = ShazamArtistService(repository) private val isrc1 = "isrc1" @Test fun test_findByIsrcToArtistNames_singleIsrc() { val artist1 = createArtist("a1", 0) val artist2 = createArtist("a2", 1) val artist3 = createArtist("a3", 2) whenever(repository.findByIsrcIn(mutableSetOf(isrc1))).thenReturn( mutableListOf(artist2, artist3, artist1) ) val result = service.findByIsrcToArtistNames(mutableSetOf(isrc1)) Assertions.assertEquals(1, result.size) Assertions.assertEquals(mutableListOf("a1", "a2", "a3"), result.get(isrc1)) } private fun createArtist(name: String, ordering: Int): ShazamArtistIsrcEntity { val artist = ShazamArtistIsrcEntity() artist.cmArtistName = name artist.ordering = ordering artist.isrc = isrc1 return artist } }