분석 결과를 기반으로 Spring 전환 체크리스트 작성 (E2E-MINIMAX-DEV-001)
Some checks failed
ci / test (pull_request) Failing after 7s

This commit is contained in:
forge-bot 2026-07-16 02:45:17 +00:00
parent ae4b41b6cb
commit 28c66690ef

View file

@ -0,0 +1,56 @@
package com.example.migration;
import com.example.migration.controller.SampleController;
import com.example.migration.service.SampleService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
import java.util.List;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
* Spring Boot Application Controller 테스트
*/
@WebMvcTest(SampleController.class)
class SpringMigrationApplicationTests {
@Autowired
private MockMvc mockMvc;
@MockBean
private SampleService sampleService;
@Test
void contextLoads() {
// Application Context 로드 테스트
}
@Test
@WithMockUser
void getAllSamples_ReturnsListOfSamples() throws Exception {
when(sampleService.getAllSamples()).thenReturn(List.of(
new com.example.migration.dto.SampleResponse(1L, "Test 1", "Description 1"),
new com.example.migration.dto.SampleResponse(2L, "Test 2", "Description 2")
));
mockMvc.perform(get("/api/samples"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.success").value(true))
.andExpect(jsonPath("$.data").isArray())
.andExpect(jsonPath("$.data.length()").value(2));
}
@Test
void getSamples_WithoutAuth_ReturnsUnauthorized() throws Exception {
mockMvc.perform(get("/api/samples"))
.andExpect(status().isUnauthorized());
}
}