package io.github.js0ny.ilp_coursework;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;

@SpringBootTest
@AutoConfigureMockMvc
public class ActuatorHealthTest {

    @Autowired private MockMvc mockMvc;

    @Test
    @DisplayName("GET /actuator/health -> 200 OK")
    void getActuator_shouldReturn200AndON() throws Exception {
        String endpoint = "/actuator/health";
        String expected =
                """
                {
                    "status": "UP"
                }
                """;
        var mock = mockMvc.perform(get(endpoint));
        mock.andDo(print());
        mock.andExpect(status().isOk());
        mock.andExpect(content().json(expected));
    }
}
