refactor: Complete updateParticipantCheckInStatus delegation to ScheduleStatusService

Phase 3 Complete:
- Update MartialScheduleServiceImpl.updateParticipantCheckInStatus to delegate
- Reduce method from 17 lines to 3 lines (delegation only)
- Add 5 comprehensive unit tests for updateParticipantCheckInStatus
- All tests passing (482 total: 477 existing + 5 new)

Delegation Status:
 exportSchedule - FULLY DELEGATED
 exportScheduleTemplate2 - FULLY DELEGATED
 updateParticipantCheckInStatus - FULLY DELEGATED (NEW)

Progress: 3/10 methods (30%)
Remaining: 7 methods to delegate
Next: Phase 4 - Dispatch Service methods (saveDispatch, adjustOrder, getDispatchData, moveScheduleGroup)
This commit is contained in:
2026-01-18 12:59:28 +08:00
parent 704c99942a
commit 9ceba84b5b
10 changed files with 80 additions and 42 deletions
Binary file not shown.
@@ -923,21 +923,8 @@ public class MartialScheduleServiceImpl extends ServiceImpl<MartialScheduleMappe
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateParticipantCheckInStatus(Long participantId, String status) {
if (participantId == null || status == null) {
return false;
}
MartialScheduleParticipant participant = scheduleParticipantMapper.selectById(participantId);
if (participant == null) {
log.warn("参赛者不存在, participantId: {}", participantId);
return false;
}
participant.setCheckInStatus(status);
int result = scheduleParticipantMapper.updateById(participant);
log.info("更新参赛者签到状态: participantId={}, status={}, result={}", participantId, status, result);
return result > 0;
// Delegated to ScheduleStatusService
return scheduleStatusService.updateParticipantCheckInStatus(participantId, status);
}
@@ -21,7 +21,9 @@ import static org.mockito.Mockito.*;
* MartialScheduleServiceImpl Test
* Following Google Testing Best Practices
*
* Phase 2 Complete: exportSchedule and exportScheduleTemplate2 fully delegated
* Completed Phases:
* - Phase 2: Export Service (exportSchedule, exportScheduleTemplate2)
* - Phase 3: Status Service (updateParticipantCheckInStatus)
*/
@DisplayName("MartialScheduleServiceImpl - Delegation Tests")
class MartialScheduleServiceImplTest {
@@ -29,6 +31,9 @@ class MartialScheduleServiceImplTest {
@Mock
private IScheduleExportService scheduleExportService;
@Mock
private IScheduleStatusService scheduleStatusService;
@InjectMocks
private MartialScheduleServiceImpl scheduleService;
@@ -37,10 +42,11 @@ class MartialScheduleServiceImplTest {
MockitoAnnotations.openMocks(this);
}
// ========== Phase 2: Export Service Tests ==========
@Test
@DisplayName("Should delegate exportSchedule to ScheduleExportService")
void shouldDelegateExportScheduleToService() {
// Given
Long competitionId = 1L;
List<ScheduleExportExcel> expectedResult = Arrays.asList(
new ScheduleExportExcel(),
@@ -48,10 +54,8 @@ class MartialScheduleServiceImplTest {
);
when(scheduleExportService.exportSchedule(competitionId)).thenReturn(expectedResult);
// When
List<ScheduleExportExcel> result = scheduleService.exportSchedule(competitionId);
// Then
assertNotNull(result);
assertEquals(2, result.size());
verify(scheduleExportService).exportSchedule(competitionId);
@@ -60,14 +64,11 @@ class MartialScheduleServiceImplTest {
@Test
@DisplayName("Should handle empty export result")
void shouldHandleEmptyExportResult() {
// Given
Long competitionId = 1L;
when(scheduleExportService.exportSchedule(competitionId)).thenReturn(new ArrayList<>());
// When
List<ScheduleExportExcel> result = scheduleService.exportSchedule(competitionId);
// Then
assertNotNull(result);
assertTrue(result.isEmpty());
verify(scheduleExportService).exportSchedule(competitionId);
@@ -76,13 +77,10 @@ class MartialScheduleServiceImplTest {
@Test
@DisplayName("Should handle null competition ID")
void shouldHandleNullCompetitionId() {
// Given
when(scheduleExportService.exportSchedule(null)).thenReturn(null);
// When
List<ScheduleExportExcel> result = scheduleService.exportSchedule(null);
// Then
assertNull(result);
verify(scheduleExportService).exportSchedule(null);
}
@@ -90,24 +88,18 @@ class MartialScheduleServiceImplTest {
@Test
@DisplayName("Should verify exportSchedule is called exactly once")
void shouldVerifyExportScheduleCalledOnce() {
// Given
Long competitionId = 1L;
when(scheduleExportService.exportSchedule(competitionId)).thenReturn(new ArrayList<>());
// When
scheduleService.exportSchedule(competitionId);
// Then
verify(scheduleExportService, times(1)).exportSchedule(competitionId);
verifyNoMoreInteractions(scheduleExportService);
}
// ========== Phase 2: exportScheduleTemplate2 Tests ==========
@Test
@DisplayName("Should delegate exportScheduleTemplate2 to ScheduleExportService")
void shouldDelegateExportScheduleTemplate2ToService() {
// Given
Long competitionId = 1L;
Long venueId = 2L;
List<ScheduleExportExcel2> expectedResult = Arrays.asList(
@@ -118,10 +110,8 @@ class MartialScheduleServiceImplTest {
when(scheduleExportService.exportScheduleTemplate2(competitionId, venueId))
.thenReturn(expectedResult);
// When
List<ScheduleExportExcel2> result = scheduleService.exportScheduleTemplate2(competitionId, venueId);
// Then
assertNotNull(result);
assertEquals(3, result.size());
verify(scheduleExportService).exportScheduleTemplate2(competitionId, venueId);
@@ -130,7 +120,6 @@ class MartialScheduleServiceImplTest {
@Test
@DisplayName("Should handle null venueId in exportScheduleTemplate2")
void shouldHandleNullVenueIdInExportScheduleTemplate2() {
// Given
Long competitionId = 1L;
List<ScheduleExportExcel2> expectedResult = Arrays.asList(
new ScheduleExportExcel2()
@@ -138,10 +127,8 @@ class MartialScheduleServiceImplTest {
when(scheduleExportService.exportScheduleTemplate2(competitionId, null))
.thenReturn(expectedResult);
// When
List<ScheduleExportExcel2> result = scheduleService.exportScheduleTemplate2(competitionId, null);
// Then
assertNotNull(result);
assertEquals(1, result.size());
verify(scheduleExportService).exportScheduleTemplate2(competitionId, null);
@@ -150,16 +137,13 @@ class MartialScheduleServiceImplTest {
@Test
@DisplayName("Should handle empty result in exportScheduleTemplate2")
void shouldHandleEmptyResultInExportScheduleTemplate2() {
// Given
Long competitionId = 1L;
Long venueId = 2L;
when(scheduleExportService.exportScheduleTemplate2(competitionId, venueId))
.thenReturn(new ArrayList<>());
// When
List<ScheduleExportExcel2> result = scheduleService.exportScheduleTemplate2(competitionId, venueId);
// Then
assertNotNull(result);
assertTrue(result.isEmpty());
verify(scheduleExportService).exportScheduleTemplate2(competitionId, venueId);
@@ -168,17 +152,84 @@ class MartialScheduleServiceImplTest {
@Test
@DisplayName("Should verify exportScheduleTemplate2 is called exactly once")
void shouldVerifyExportScheduleTemplate2CalledOnce() {
// Given
Long competitionId = 1L;
Long venueId = 2L;
when(scheduleExportService.exportScheduleTemplate2(competitionId, venueId))
.thenReturn(new ArrayList<>());
// When
scheduleService.exportScheduleTemplate2(competitionId, venueId);
// Then
verify(scheduleExportService, times(1)).exportScheduleTemplate2(competitionId, venueId);
verifyNoMoreInteractions(scheduleExportService);
}
// ========== Phase 3: Status Service Tests ==========
@Test
@DisplayName("Should delegate updateParticipantCheckInStatus to ScheduleStatusService")
void shouldDelegateUpdateParticipantCheckInStatus() {
Long participantId = 1L;
String status = "CHECKED_IN";
when(scheduleStatusService.updateParticipantCheckInStatus(participantId, status))
.thenReturn(true);
boolean result = scheduleService.updateParticipantCheckInStatus(participantId, status);
assertTrue(result);
verify(scheduleStatusService).updateParticipantCheckInStatus(participantId, status);
}
@Test
@DisplayName("Should handle null participantId in updateParticipantCheckInStatus")
void shouldHandleNullParticipantId() {
String status = "CHECKED_IN";
when(scheduleStatusService.updateParticipantCheckInStatus(null, status))
.thenReturn(false);
boolean result = scheduleService.updateParticipantCheckInStatus(null, status);
assertFalse(result);
verify(scheduleStatusService).updateParticipantCheckInStatus(null, status);
}
@Test
@DisplayName("Should handle null status in updateParticipantCheckInStatus")
void shouldHandleNullStatus() {
Long participantId = 1L;
when(scheduleStatusService.updateParticipantCheckInStatus(participantId, null))
.thenReturn(false);
boolean result = scheduleService.updateParticipantCheckInStatus(participantId, null);
assertFalse(result);
verify(scheduleStatusService).updateParticipantCheckInStatus(participantId, null);
}
@Test
@DisplayName("Should handle update failure in updateParticipantCheckInStatus")
void shouldHandleUpdateFailure() {
Long participantId = 999L;
String status = "CHECKED_IN";
when(scheduleStatusService.updateParticipantCheckInStatus(participantId, status))
.thenReturn(false);
boolean result = scheduleService.updateParticipantCheckInStatus(participantId, status);
assertFalse(result);
verify(scheduleStatusService).updateParticipantCheckInStatus(participantId, status);
}
@Test
@DisplayName("Should verify updateParticipantCheckInStatus is called exactly once")
void shouldVerifyUpdateParticipantCheckInStatusCalledOnce() {
Long participantId = 1L;
String status = "CHECKED_IN";
when(scheduleStatusService.updateParticipantCheckInStatus(participantId, status))
.thenReturn(true);
scheduleService.updateParticipantCheckInStatus(participantId, status);
verify(scheduleStatusService, times(1)).updateParticipantCheckInStatus(participantId, status);
verifyNoMoreInteractions(scheduleStatusService);
}
}