package com.mattrixwv.cipherstream.controller; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; import java.io.IOException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.aop.AopAutoConfiguration; import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.context.annotation.Import; import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; import org.springframework.test.web.servlet.MockMvc; import com.mattrixwv.cipherstream.aspect.CipherStreamLoggingAspect; import com.mattrixwv.cipherstream.config.FullFilter; import jakarta.servlet.ServletException; import tools.jackson.databind.ObjectMapper; import tools.jackson.databind.node.ObjectNode; @Tag("integration-test") @WebMvcTest(controllers = HealthCheckController.class) @Import({AopAutoConfiguration.class, FullFilter.class, CipherStreamLoggingAspect.class}) public class HealthCheckControllerIntegrationTest{ @Autowired private MockMvc mockMvc; @MockitoSpyBean private FullFilter fullFilter; //Fields protected ObjectMapper mapper; protected ObjectNode blankNode; @BeforeEach public void setupJson(){ mapper = new ObjectMapper(); blankNode = mapper.createObjectNode(); } @AfterEach public void checkFilter() throws ServletException, IOException{ verify(fullFilter, times(1)).doFilter(any(), any(), any()); } @Test public void testHealthCheck() throws Exception{ mockMvc.perform(options("/health")) .andExpect(status().isOk()); } }