package space.nstart.pcp.pcp_types_lib.dto.ballistics

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.time.LocalDateTime
import kotlin.test.assertFalse

class AngularMotionCalculationRequestDTOJacksonTest {

    private val mapper = jacksonObjectMapper().registerModule(JavaTimeModule())

    @Test
    fun `deserializes calculation request contract`() {
        val request = mapper.readValue<AngularMotionCalculationRequestDTO>(
            """
            {
              "satelliteId": 123,
              "approximateTime": "2026-06-15T10:30:00",
              "mode": "CONST_ORIENT",
              "latitudeDeg": 55.75,
              "longitudeDeg": 37.61,
              "heightM": 0,
              "durationSec": 60,
              "captureAngleDeg": 1.5,
              "leadAngleDeg": 0,
              "azimuthDeg": 0,
              "pointInCenter": false,
              "focusMm": 5500,
              "stepPuudSec": 0.125
            }
            """.trimIndent(),
        )

        assertEquals(123L, request.satelliteId)
        assertEquals(LocalDateTime.of(2026, 6, 15, 10, 30), request.approximateTime)
        assertEquals(AngularMotionModeDTO.CONST_ORIENT, request.mode)
        assertEquals(55.75, request.latitudeDeg)
        assertEquals(37.61, request.longitudeDeg)
        assertEquals(1.5, request.captureAngleDeg)
        assertFalse(request.pointInCenter)
    }
}
