package space.nstart.pcp.slots_service.controller

import org.junit.jupiter.api.Test
import org.mockito.Mockito.mock
import org.mockito.Mockito.verifyNoInteractions
import org.springframework.http.MediaType
import org.springframework.test.util.ReflectionTestUtils
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
import org.springframework.test.web.servlet.setup.MockMvcBuilders
import space.nstart.pcp.slots_service.service.SlotService
import kotlin.test.assertTrue

class BookingControllerTest {

    private val slotService = mock(SlotService::class.java)
    private val controller = BookingController().also {
        ReflectionTestUtils.setField(it, "slotService", slotService)
    }
    private val mockMvc: MockMvc = MockMvcBuilders.standaloneSetup(controller).build()

    @Test
    fun `legacy process endpoint returns gone and does not update booked slots`() {
        val result = mockMvc.perform(
            post("/api/slots/booking/process")
                .contentType(MediaType.APPLICATION_JSON)
                .content("[10,20]")
        )
            .andExpect(status().isGone)
            .andReturn()

        assertTrue(result.resolvedException?.message?.contains("Legacy booked slots HTTP processing is retired") == true)

        verifyNoInteractions(slotService)
    }
}
