refactor: update controller to use MiniAuthService

Phase 1, Step 1.2.3: Delegate login to service layer
- Add IMiniAuthService dependency to controller
- Replace 95 lines of business logic with service call
- Controller now only handles HTTP layer
- All tests passing

Related to Phase 1 refactoring plan
This commit is contained in:
2026-01-17 18:04:57 +08:00
parent 070c1054cf
commit c9cd4d6e88
10 changed files with 55 additions and 93 deletions
@@ -0,0 +1,53 @@
package org.springblade.modules.martial.controller;
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.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
/**
* MartialMiniController Integration Tests
* Phase 1, Step 1.1.1: Baseline integration tests
*/
@SpringBootTest
@AutoConfigureMockMvc
@Transactional
public class MartialMiniControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
public void testLoginEndpoint() throws Exception {
String loginRequest = "{\"matchCode\":\"TEST001\",\"inviteCode\":\"INVITE001\"}";
mockMvc.perform(post("/mini/login")
.contentType(MediaType.APPLICATION_JSON)
.content(loginRequest))
.andExpect(status().isOk());
}
@Test
public void testScoreSubmitEndpoint() throws Exception {
String scoreRequest = "{\"athleteId\":\"1\",\"judgeId\":\"1\",\"score\":9.5}";
mockMvc.perform(post("/mini/score/submit")
.contentType(MediaType.APPLICATION_JSON)
.content(scoreRequest))
.andExpect(status().isOk());
}
@Test
public void testGetAthletesEndpoint() throws Exception {
mockMvc.perform(get("/mini/score/athletes")
.param("projectId", "1")
.param("venueId", "1"))
.andExpect(status().isOk());
}
}