package space.nstart.pcp.pcp_satellites_service.service

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Primary
import org.springframework.context.annotation.Profile
import space.nstart.pcp.pcp_types_lib.dto.satellite.SatelliteDTO
import space.nstart.pcp.pcp_types_lib.dto.satellite.SatelliteObservationProfileDTO
import space.nstart.pcp.pcp_types_lib.dto.satellite.SatelliteVisualizationDTO

fun testSatelliteCatalogClient(): SatelliteCatalogClient = object : SatelliteCatalogClient {
    override fun allSatellites(): List<SatelliteDTO> = listOf(
        satelliteDto(10L, "Reflexio", SatelliteVisualizationDTO(125, 125, 78)),
        satelliteDto(11L, "Reflexio", SatelliteVisualizationDTO(125, 125, 78)),
        satelliteDto(22L, "Emissio", SatelliteVisualizationDTO(0, 125, 0)),
        satelliteDto(56756L, "KONDOR-FKA NO. 1", SatelliteVisualizationDTO(255, 0, 0), scanTle = true),
        satelliteDto(62138L, "KONDOR-FKA NO. 2", SatelliteVisualizationDTO(255, 125, 0), scanTle = true)
    )
}

private fun satelliteDto(
    id: Long,
    name: String,
    visualization: SatelliteVisualizationDTO,
    scanTle: Boolean = false
) = SatelliteDTO(
    id = id,
    noradId = if (scanTle) id else null,
    code = "TEST-$id",
    name = name,
    typeCode = name.uppercase().replace(' ', '_'),
    active = true,
    scanTle = scanTle,
    visualization = visualization,
    observationProfile = SatelliteObservationProfileDTO()
)

@Configuration
@Profile("test")
class TestSatelliteCatalogClientConfiguration {

    @Bean
    @Primary
    fun satelliteCatalogClient(): SatelliteCatalogClient = testSatelliteCatalogClient()
}
