package space.nstart.pcp.pcp_mission_planing_service.service.satellite_type

import org.junit.jupiter.api.Assertions.assertSame
import org.junit.jupiter.api.Test
import space.nstart.pcp.pcp_types_lib.dto.satellite.SatelliteDTO

class SatelliteMissionTypeFactoryTest {
    private val defaultType = DefaultSatelliteMissionType()
    private val emissioType = EmissioSatelliteMissionType()
    private val reflixioType = ReflixioSatelliteMissionType()
    private val factory = SatelliteMissionTypeFactory(
        missionTypes = listOf(defaultType, emissioType, reflixioType),
        defaultMissionType = defaultType
    )

    @Test
    fun `returns Emissio type by satellite dto typeCode ignoring case`() {
        val type = factory.getBySatellite(SatelliteDTO(id = 1, typeCode = "Emissio"))

        assertSame(emissioType, type)
    }

    @Test
    fun `returns Reflixio type by satellite dto typeCode ignoring case`() {
        val type = factory.getBySatellite(SatelliteDTO(id = 2, typeCode = "reflixio"))

        assertSame(reflixioType, type)
    }

    @Test
    fun `returns default type for blank or unknown typeCode`() {
        assertSame(defaultType, factory.getBySatellite(SatelliteDTO(id = 3, typeCode = "")))
        assertSame(defaultType, factory.getBySatellite(SatelliteDTO(id = 4, typeCode = "unknown")))
    }
}
