diff --git a/minio_data/.minio.sys/buckets/.bloomcycle.bin/xl.meta b/minio_data/.minio.sys/buckets/.bloomcycle.bin/xl.meta index 1107eaf..987005d 100644 Binary files a/minio_data/.minio.sys/buckets/.bloomcycle.bin/xl.meta and b/minio_data/.minio.sys/buckets/.bloomcycle.bin/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/.usage-cache.bin.bkp/xl.meta b/minio_data/.minio.sys/buckets/.usage-cache.bin.bkp/xl.meta index 4604cbc..f64119f 100644 Binary files a/minio_data/.minio.sys/buckets/.usage-cache.bin.bkp/xl.meta and b/minio_data/.minio.sys/buckets/.usage-cache.bin.bkp/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/.usage-cache.bin/xl.meta b/minio_data/.minio.sys/buckets/.usage-cache.bin/xl.meta index deac5a5..0561aa2 100644 Binary files a/minio_data/.minio.sys/buckets/.usage-cache.bin/xl.meta and b/minio_data/.minio.sys/buckets/.usage-cache.bin/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/.usage.json/xl.meta b/minio_data/.minio.sys/buckets/.usage.json/xl.meta index 80311f2..2c36141 100644 Binary files a/minio_data/.minio.sys/buckets/.usage.json/xl.meta and b/minio_data/.minio.sys/buckets/.usage.json/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin.bkp/xl.meta b/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin.bkp/xl.meta index cdb88e4..fd2138c 100644 Binary files a/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin.bkp/xl.meta and b/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin.bkp/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin/xl.meta b/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin/xl.meta index a483a83..3c9b9c5 100644 Binary files a/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin/xl.meta and b/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/assets/.usage-cache.bin.bkp/xl.meta b/minio_data/.minio.sys/buckets/assets/.usage-cache.bin.bkp/xl.meta index 9d30918..30cffe5 100644 Binary files a/minio_data/.minio.sys/buckets/assets/.usage-cache.bin.bkp/xl.meta and b/minio_data/.minio.sys/buckets/assets/.usage-cache.bin.bkp/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/assets/.usage-cache.bin/xl.meta b/minio_data/.minio.sys/buckets/assets/.usage-cache.bin/xl.meta index 37fa113..93bc340 100644 Binary files a/minio_data/.minio.sys/buckets/assets/.usage-cache.bin/xl.meta and b/minio_data/.minio.sys/buckets/assets/.usage-cache.bin/xl.meta differ diff --git a/src/test/java/org/springblade/modules/martial/service/impl/MartialScheduleServiceImplTest.java b/src/test/java/org/springblade/modules/martial/service/impl/MartialScheduleServiceImplTest.java new file mode 100644 index 0000000..2815b98 --- /dev/null +++ b/src/test/java/org/springblade/modules/martial/service/impl/MartialScheduleServiceImplTest.java @@ -0,0 +1,110 @@ +package org.springblade.modules.martial.service.impl; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.springblade.modules.martial.excel.ScheduleExportExcel; +import org.springblade.modules.martial.service.*; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * MartialScheduleServiceImpl Test + * Following Google Testing Best Practices + * + * IMPORTANT NOTE: + * This service is only PARTIALLY refactored. Most methods still use Mappers directly. + * Only exportSchedule() is fully delegated to ScheduleExportService. + * + * Other methods (saveDraftSchedule, saveAndLockSchedule, adjustOrder, saveDispatch, etc.) + * still contain business logic and Mapper calls - they need further refactoring. + * + * This test focuses on what IS delegated, not what SHOULD BE delegated. + */ +@DisplayName("MartialScheduleServiceImpl - Delegation Tests") +class MartialScheduleServiceImplTest { + + @Mock + private IScheduleExportService scheduleExportService; + + @InjectMocks + private MartialScheduleServiceImpl scheduleService; + + @BeforeEach + void setUp() { + MockitoAnnotations.openMocks(this); + } + + @Test + @DisplayName("Should delegate exportSchedule to ScheduleExportService") + void shouldDelegateExportScheduleToService() { + // Given + Long competitionId = 1L; + List expectedResult = Arrays.asList( + new ScheduleExportExcel(), + new ScheduleExportExcel() + ); + when(scheduleExportService.exportSchedule(competitionId)).thenReturn(expectedResult); + + // When + List result = scheduleService.exportSchedule(competitionId); + + // Then + assertNotNull(result); + assertEquals(2, result.size()); + verify(scheduleExportService).exportSchedule(competitionId); + } + + @Test + @DisplayName("Should handle empty export result") + void shouldHandleEmptyExportResult() { + // Given + Long competitionId = 1L; + when(scheduleExportService.exportSchedule(competitionId)).thenReturn(new ArrayList<>()); + + // When + List result = scheduleService.exportSchedule(competitionId); + + // Then + assertNotNull(result); + assertTrue(result.isEmpty()); + verify(scheduleExportService).exportSchedule(competitionId); + } + + @Test + @DisplayName("Should handle null competition ID") + void shouldHandleNullCompetitionId() { + // Given + when(scheduleExportService.exportSchedule(null)).thenReturn(null); + + // When + List result = scheduleService.exportSchedule(null); + + // Then + assertNull(result); + verify(scheduleExportService).exportSchedule(null); + } + + @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); + } +}