|
|
|
@ -12,6 +12,8 @@ import com.sztzjy.linkCommerce.mapper.TaskAllocationMapper;
|
|
|
|
import com.sztzjy.linkCommerce.mapper.TeachingClassStudentMapper;
|
|
|
|
import com.sztzjy.linkCommerce.mapper.TeachingClassStudentMapper;
|
|
|
|
import com.sztzjy.linkCommerce.mapper.TrainingTaskClassConfigMapper;
|
|
|
|
import com.sztzjy.linkCommerce.mapper.TrainingTaskClassConfigMapper;
|
|
|
|
import com.sztzjy.linkCommerce.mapper.TrainingTaskMapper;
|
|
|
|
import com.sztzjy.linkCommerce.mapper.TrainingTaskMapper;
|
|
|
|
|
|
|
|
import com.sztzjy.linkCommerce.service.TrainingKnowledgeService;
|
|
|
|
|
|
|
|
import com.sztzjy.linkCommerce.training.knowledge.EffectiveTrainingTaskContent;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.mockito.ArgumentCaptor;
|
|
|
|
import org.mockito.ArgumentCaptor;
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
@ -52,6 +54,37 @@ class TrainingTaskServiceImplTest {
|
|
|
|
verify(service.jdbcTemplate, never()).execute(contains("task_allocation"));
|
|
|
|
verify(service.jdbcTemplate, never()).execute(contains("task_allocation"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void reindexCaseMaterialsKeepsDefaultAndTeachingClassCasesSeparated() {
|
|
|
|
|
|
|
|
TrainingTaskServiceImpl service = new TrainingTaskServiceImpl();
|
|
|
|
|
|
|
|
service.trainingTaskMapper = mock(TrainingTaskMapper.class);
|
|
|
|
|
|
|
|
service.trainingTaskClassConfigMapper = mock(TrainingTaskClassConfigMapper.class);
|
|
|
|
|
|
|
|
service.trainingKnowledgeService = mock(TrainingKnowledgeService.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TrainingTask task = storedTask("task-1", "new-product-survey");
|
|
|
|
|
|
|
|
task.setMaterialName("管理员案例.docx");
|
|
|
|
|
|
|
|
task.setMaterialUrl("/file/admin-case.docx");
|
|
|
|
|
|
|
|
TrainingTaskClassConfig teacherConfig = overrideTask("config-1", "class-1", "new-product-survey");
|
|
|
|
|
|
|
|
teacherConfig.setMaterialName("教师案例.docx");
|
|
|
|
|
|
|
|
teacherConfig.setMaterialUrl("/file/teacher-case.docx");
|
|
|
|
|
|
|
|
when(service.trainingTaskMapper.selectList(null, null, null)).thenReturn(List.of(task));
|
|
|
|
|
|
|
|
when(service.trainingTaskClassConfigMapper.selectAll()).thenReturn(List.of(teacherConfig));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int indexed = service.reindexCaseMaterials();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(2, indexed);
|
|
|
|
|
|
|
|
ArgumentCaptor<EffectiveTrainingTaskContent> contentCaptor = ArgumentCaptor.forClass(EffectiveTrainingTaskContent.class);
|
|
|
|
|
|
|
|
ArgumentCaptor<String> classCaptor = ArgumentCaptor.forClass(String.class);
|
|
|
|
|
|
|
|
verify(service.trainingKnowledgeService, times(2)).indexCaseMaterial(org.mockito.ArgumentMatchers.eq(task),
|
|
|
|
|
|
|
|
contentCaptor.capture(), classCaptor.capture());
|
|
|
|
|
|
|
|
assertEquals("ADMIN", contentCaptor.getAllValues().get(0).getScope());
|
|
|
|
|
|
|
|
assertEquals("task-1", contentCaptor.getAllValues().get(0).getEffectiveConfigId());
|
|
|
|
|
|
|
|
assertEquals("TEACHER", contentCaptor.getAllValues().get(1).getScope());
|
|
|
|
|
|
|
|
assertEquals("config-1", contentCaptor.getAllValues().get(1).getEffectiveConfigId());
|
|
|
|
|
|
|
|
assertNull(classCaptor.getAllValues().get(0));
|
|
|
|
|
|
|
|
assertEquals("class-1", classCaptor.getAllValues().get(1));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void splitListSupportsCommonSeparators() {
|
|
|
|
void splitListSupportsCommonSeparators() {
|
|
|
|
TrainingTaskServiceImpl service = new TrainingTaskServiceImpl();
|
|
|
|
TrainingTaskServiceImpl service = new TrainingTaskServiceImpl();
|
|
|
|
|