@ -67,8 +67,8 @@ class TrainingTaskServiceImplTest {
TrainingTaskClassConfig teacherConfig = overrideTask ( "config-1" , "class-1" , "new-product-survey" ) ;
TrainingTaskClassConfig teacherConfig = overrideTask ( "config-1" , "class-1" , "new-product-survey" ) ;
teacherConfig . setMaterialName ( "教师案例.docx" ) ;
teacherConfig . setMaterialName ( "教师案例.docx" ) ;
teacherConfig . setMaterialUrl ( "/file/teacher-case.docx" ) ;
teacherConfig . setMaterialUrl ( "/file/teacher-case.docx" ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( List. of ( task ) ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( java. util . Arrays . asList ( task ) ) ;
when ( service . trainingTaskClassConfigMapper . selectAll ( ) ) . thenReturn ( List. of ( teacherConfig ) ) ;
when ( service . trainingTaskClassConfigMapper . selectAll ( ) ) . thenReturn ( java. util . Arrays . asList ( teacherConfig ) ) ;
int indexed = service . reindexCaseMaterials ( ) ;
int indexed = service . reindexCaseMaterials ( ) ;
@ -205,7 +205,7 @@ class TrainingTaskServiceImplTest {
SchoolClass defaultClass = teachingClass ( "class-default" , "teacher-1" ) ;
SchoolClass defaultClass = teachingClass ( "class-default" , "teacher-1" ) ;
SchoolClass customizedClass = teachingClass ( "class-customized" , "teacher-2" ) ;
SchoolClass customizedClass = teachingClass ( "class-customized" , "teacher-2" ) ;
when ( service . schoolClassMapper . selectByExample ( any ( ) ) ) . thenReturn ( List. of ( defaultClass , customizedClass ) ) ;
when ( service . schoolClassMapper . selectByExample ( any ( ) ) ) . thenReturn ( java. util . Arrays . asList ( defaultClass , customizedClass ) ) ;
TrainingTaskClassConfig defaultConfig = overrideTask ( "config-default" , "class-default" , "new-product-survey" ) ;
TrainingTaskClassConfig defaultConfig = overrideTask ( "config-default" , "class-default" , "new-product-survey" ) ;
defaultConfig . setTaskName ( "Original Name" ) ;
defaultConfig . setTaskName ( "Original Name" ) ;
@ -750,15 +750,15 @@ class TrainingTaskServiceImplTest {
TrainingTaskServiceImpl service = studentTaskService ( "class-1" ) ;
TrainingTaskServiceImpl service = studentTaskService ( "class-1" ) ;
TrainingTask legacy = storedTask ( "task-1" , "new-product-survey" ) ;
TrainingTask legacy = storedTask ( "task-1" , "new-product-survey" ) ;
TrainingTask comprehensive = comprehensiveTrainingTask ( ) ;
TrainingTask comprehensive = comprehensiveTrainingTask ( ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( List. of ( legacy , comprehensive ) ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( java. util . Arrays . asList ( legacy , comprehensive ) ) ;
when ( service . trainingTaskClassConfigMapper . selectListByTeachingClass ( "class-1" , null ) )
when ( service . trainingTaskClassConfigMapper . selectListByTeachingClass ( "class-1" , null ) )
. thenReturn ( List. of ( overrideTask ( "config-1" , "class-1" , "new-product-survey" ) ,
. thenReturn ( java. util . Arrays . asList ( overrideTask ( "config-1" , "class-1" , "new-product-survey" ) ,
overrideTask ( "config-2" , "class-1" , "comprehensive-case-training" ) ) ) ;
overrideTask ( "config-2" , "class-1" , "comprehensive-case-training" ) ) ) ;
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( Collections . emptyList ( ) ) ;
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( Collections . emptyList ( ) ) ;
List < TrainingTask > result = service . listForStudent ( "stu-1" , true ) ;
List < TrainingTask > result = service . listForStudent ( "stu-1" , true ) ;
assertEquals ( List. of ( "new-product-survey" ) , result . stream ( )
assertEquals ( java. util . Arrays . asList ( "new-product-survey" ) , result . stream ( )
. map ( TrainingTask : : getTaskKey )
. map ( TrainingTask : : getTaskKey )
. collect ( java . util . stream . Collectors . toList ( ) ) ) ;
. collect ( java . util . stream . Collectors . toList ( ) ) ) ;
}
}
@ -782,7 +782,7 @@ class TrainingTaskServiceImplTest {
when ( service . trainingTaskMapper . selectByTaskKey ( "comprehensive-case-training" ) ) . thenReturn ( comprehensive ) ;
when ( service . trainingTaskMapper . selectByTaskKey ( "comprehensive-case-training" ) ) . thenReturn ( comprehensive ) ;
when ( service . trainingTaskClassConfigMapper . selectByTeachingClassAndTaskKey ( "class-1" , "comprehensive-case-training" ) )
when ( service . trainingTaskClassConfigMapper . selectByTeachingClassAndTaskKey ( "class-1" , "comprehensive-case-training" ) )
. thenReturn ( overrideTask ( "config-1" , "class-1" , "comprehensive-case-training" ) ) ;
. thenReturn ( overrideTask ( "config-1" , "class-1" , "comprehensive-case-training" ) ) ;
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( List. of (
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( java. util . Arrays . asList (
taskAllocation ( TaskAllocation . PUBLICATION_MARKER , ( byte ) 1 ) ,
taskAllocation ( TaskAllocation . PUBLICATION_MARKER , ( byte ) 1 ) ,
taskAllocation ( "comprehensive-case-training" , ( byte ) 0 ) ) ) ;
taskAllocation ( "comprehensive-case-training" , ( byte ) 0 ) ) ) ;
@ -800,7 +800,7 @@ class TrainingTaskServiceImplTest {
disabled . setEnabled ( Boolean . FALSE ) ;
disabled . setEnabled ( Boolean . FALSE ) ;
when ( service . trainingTaskClassConfigMapper . selectByTeachingClassAndTaskKey ( "class-1" , "comprehensive-case-training" ) )
when ( service . trainingTaskClassConfigMapper . selectByTeachingClassAndTaskKey ( "class-1" , "comprehensive-case-training" ) )
. thenReturn ( disabled ) ;
. thenReturn ( disabled ) ;
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( List. of (
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( java. util . Arrays . asList (
taskAllocation ( TaskAllocation . PUBLICATION_MARKER , ( byte ) 1 ) ,
taskAllocation ( TaskAllocation . PUBLICATION_MARKER , ( byte ) 1 ) ,
taskAllocation ( "comprehensive-case-training" , ( byte ) 0 ) ) ) ;
taskAllocation ( "comprehensive-case-training" , ( byte ) 0 ) ) ) ;
@ -814,18 +814,18 @@ class TrainingTaskServiceImplTest {
TrainingTaskServiceImpl service = studentTaskService ( "class-1" ) ;
TrainingTaskServiceImpl service = studentTaskService ( "class-1" ) ;
TrainingTask legacy = storedTask ( "task-1" , "new-product-survey" ) ;
TrainingTask legacy = storedTask ( "task-1" , "new-product-survey" ) ;
TrainingTask comprehensive = comprehensiveTrainingTask ( ) ;
TrainingTask comprehensive = comprehensiveTrainingTask ( ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( List. of ( legacy , comprehensive ) ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( java. util . Arrays . asList ( legacy , comprehensive ) ) ;
when ( service . trainingTaskClassConfigMapper . selectListByTeachingClass ( "class-1" , null ) )
when ( service . trainingTaskClassConfigMapper . selectListByTeachingClass ( "class-1" , null ) )
. thenReturn ( List. of ( overrideTask ( "config-1" , "class-1" , "new-product-survey" ) ,
. thenReturn ( java. util . Arrays . asList ( overrideTask ( "config-1" , "class-1" , "new-product-survey" ) ,
overrideTask ( "config-2" , "class-1" , "comprehensive-case-training" ) ) ) ;
overrideTask ( "config-2" , "class-1" , "comprehensive-case-training" ) ) ) ;
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( List. of (
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( java. util . Arrays . asList (
taskAllocation ( TaskAllocation . PUBLICATION_MARKER , ( byte ) 1 ) ,
taskAllocation ( TaskAllocation . PUBLICATION_MARKER , ( byte ) 1 ) ,
taskAllocation ( "new-product-survey" , ( byte ) 0 ) ,
taskAllocation ( "new-product-survey" , ( byte ) 0 ) ,
taskAllocation ( "comprehensive-case-training" , ( byte ) 0 ) ) ) ;
taskAllocation ( "comprehensive-case-training" , ( byte ) 0 ) ) ) ;
List < TrainingTask > result = service . listForStudent ( "stu-1" , true ) ;
List < TrainingTask > result = service . listForStudent ( "stu-1" , true ) ;
assertEquals ( List. of ( "new-product-survey" , "comprehensive-case-training" ) , result . stream ( )
assertEquals ( java. util . Arrays . asList ( "new-product-survey" , "comprehensive-case-training" ) , result . stream ( )
. map ( TrainingTask : : getTaskKey )
. map ( TrainingTask : : getTaskKey )
. collect ( java . util . stream . Collectors . toList ( ) ) ) ;
. collect ( java . util . stream . Collectors . toList ( ) ) ) ;
}
}
@ -835,17 +835,17 @@ class TrainingTaskServiceImplTest {
TrainingTaskServiceImpl service = studentTaskService ( "class-1" ) ;
TrainingTaskServiceImpl service = studentTaskService ( "class-1" ) ;
TrainingTask legacy = storedTask ( "task-1" , "new-product-survey" ) ;
TrainingTask legacy = storedTask ( "task-1" , "new-product-survey" ) ;
TrainingTask comprehensive = comprehensiveTrainingTask ( ) ;
TrainingTask comprehensive = comprehensiveTrainingTask ( ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( List. of ( legacy , comprehensive ) ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( java. util . Arrays . asList ( legacy , comprehensive ) ) ;
when ( service . trainingTaskClassConfigMapper . selectListByTeachingClass ( "class-1" , null ) )
when ( service . trainingTaskClassConfigMapper . selectListByTeachingClass ( "class-1" , null ) )
. thenReturn ( List. of ( overrideTask ( "config-1" , "class-1" , "new-product-survey" ) ,
. thenReturn ( java. util . Arrays . asList ( overrideTask ( "config-1" , "class-1" , "new-product-survey" ) ,
overrideTask ( "config-2" , "class-1" , "comprehensive-case-training" ) ) ) ;
overrideTask ( "config-2" , "class-1" , "comprehensive-case-training" ) ) ) ;
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( List. of (
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( java. util . Arrays . asList (
taskAllocation ( TaskAllocation . PUBLICATION_MARKER , ( byte ) 1 ) ,
taskAllocation ( TaskAllocation . PUBLICATION_MARKER , ( byte ) 1 ) ,
taskAllocation ( "new-product-survey" , ( byte ) 0 ) ) ) ;
taskAllocation ( "new-product-survey" , ( byte ) 0 ) ) ) ;
List < TrainingTask > result = service . listForStudent ( "stu-1" , true ) ;
List < TrainingTask > result = service . listForStudent ( "stu-1" , true ) ;
assertEquals ( List. of ( "new-product-survey" ) , result . stream ( )
assertEquals ( java. util . Arrays . asList ( "new-product-survey" ) , result . stream ( )
. map ( TrainingTask : : getTaskKey )
. map ( TrainingTask : : getTaskKey )
. collect ( java . util . stream . Collectors . toList ( ) ) ) ;
. collect ( java . util . stream . Collectors . toList ( ) ) ) ;
}
}
@ -855,18 +855,18 @@ class TrainingTaskServiceImplTest {
TrainingTaskServiceImpl service = studentTaskService ( "class-1" ) ;
TrainingTaskServiceImpl service = studentTaskService ( "class-1" ) ;
TrainingTask legacy = storedTask ( "task-1" , "new-product-survey" ) ;
TrainingTask legacy = storedTask ( "task-1" , "new-product-survey" ) ;
TrainingTask comprehensive = comprehensiveTrainingTask ( ) ;
TrainingTask comprehensive = comprehensiveTrainingTask ( ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( List. of ( legacy , comprehensive ) ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( java. util . Arrays . asList ( legacy , comprehensive ) ) ;
when ( service . trainingTaskClassConfigMapper . selectListByTeachingClass ( "class-1" , null ) )
when ( service . trainingTaskClassConfigMapper . selectListByTeachingClass ( "class-1" , null ) )
. thenReturn ( List. of ( overrideTask ( "config-1" , "class-1" , "new-product-survey" ) ,
. thenReturn ( java. util . Arrays . asList ( overrideTask ( "config-1" , "class-1" , "new-product-survey" ) ,
overrideTask ( "config-2" , "class-1" , "comprehensive-case-training" ) ) ) ;
overrideTask ( "config-2" , "class-1" , "comprehensive-case-training" ) ) ) ;
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( List. of (
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( java. util . Arrays . asList (
taskAllocation ( TaskAllocation . PUBLICATION_MARKER , ( byte ) 1 ) ,
taskAllocation ( TaskAllocation . PUBLICATION_MARKER , ( byte ) 1 ) ,
taskAllocation ( "new-product-survey" , ( byte ) 0 ) ,
taskAllocation ( "new-product-survey" , ( byte ) 0 ) ,
taskAllocation ( "comprehensive-case-training" , ( byte ) 1 ) ) ) ;
taskAllocation ( "comprehensive-case-training" , ( byte ) 1 ) ) ) ;
List < TrainingTask > result = service . listForStudent ( "stu-1" , true ) ;
List < TrainingTask > result = service . listForStudent ( "stu-1" , true ) ;
assertEquals ( List. of ( "new-product-survey" ) , result . stream ( )
assertEquals ( java. util . Arrays . asList ( "new-product-survey" ) , result . stream ( )
. map ( TrainingTask : : getTaskKey )
. map ( TrainingTask : : getTaskKey )
. collect ( java . util . stream . Collectors . toList ( ) ) ) ;
. collect ( java . util . stream . Collectors . toList ( ) ) ) ;
}
}
@ -876,19 +876,19 @@ class TrainingTaskServiceImplTest {
TrainingTaskServiceImpl service = studentTaskService ( "class-1" ) ;
TrainingTaskServiceImpl service = studentTaskService ( "class-1" ) ;
TrainingTask legacy = storedTask ( "task-1" , "new-product-survey" ) ;
TrainingTask legacy = storedTask ( "task-1" , "new-product-survey" ) ;
TrainingTask comprehensive = comprehensiveTrainingTask ( ) ;
TrainingTask comprehensive = comprehensiveTrainingTask ( ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( List. of ( legacy , comprehensive ) ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( java. util . Arrays . asList ( legacy , comprehensive ) ) ;
TrainingTaskClassConfig disabled = overrideTask ( "config-2" , "class-1" , "comprehensive-case-training" ) ;
TrainingTaskClassConfig disabled = overrideTask ( "config-2" , "class-1" , "comprehensive-case-training" ) ;
disabled . setEnabled ( Boolean . FALSE ) ;
disabled . setEnabled ( Boolean . FALSE ) ;
when ( service . trainingTaskClassConfigMapper . selectListByTeachingClass ( "class-1" , null ) )
when ( service . trainingTaskClassConfigMapper . selectListByTeachingClass ( "class-1" , null ) )
. thenReturn ( List. of ( overrideTask ( "config-1" , "class-1" , "new-product-survey" ) , disabled ) ) ;
. thenReturn ( java. util . Arrays . asList ( overrideTask ( "config-1" , "class-1" , "new-product-survey" ) , disabled ) ) ;
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( List. of (
when ( service . taskAllocationMapper . selectByExample ( any ( ) ) ) . thenReturn ( java. util . Arrays . asList (
taskAllocation ( TaskAllocation . PUBLICATION_MARKER , ( byte ) 1 ) ,
taskAllocation ( TaskAllocation . PUBLICATION_MARKER , ( byte ) 1 ) ,
taskAllocation ( "new-product-survey" , ( byte ) 0 ) ,
taskAllocation ( "new-product-survey" , ( byte ) 0 ) ,
taskAllocation ( "comprehensive-case-training" , ( byte ) 0 ) ) ) ;
taskAllocation ( "comprehensive-case-training" , ( byte ) 0 ) ) ) ;
List < TrainingTask > result = service . listForStudent ( "stu-1" , false ) ;
List < TrainingTask > result = service . listForStudent ( "stu-1" , false ) ;
assertEquals ( List. of ( "new-product-survey" ) , result . stream ( )
assertEquals ( java. util . Arrays . asList ( "new-product-survey" ) , result . stream ( )
. map ( TrainingTask : : getTaskKey )
. map ( TrainingTask : : getTaskKey )
. collect ( java . util . stream . Collectors . toList ( ) ) ) ;
. collect ( java . util . stream . Collectors . toList ( ) ) ) ;
}
}
@ -900,7 +900,7 @@ class TrainingTaskServiceImplTest {
service . trainingTaskClassConfigMapper = mock ( TrainingTaskClassConfigMapper . class ) ;
service . trainingTaskClassConfigMapper = mock ( TrainingTaskClassConfigMapper . class ) ;
service . schoolClassMapper = mock ( SchoolClassMapper . class ) ;
service . schoolClassMapper = mock ( SchoolClassMapper . class ) ;
TrainingTask comprehensive = comprehensiveTrainingTask ( ) ;
TrainingTask comprehensive = comprehensiveTrainingTask ( ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( List. of ( comprehensive ) ) ;
when ( service . trainingTaskMapper . selectList ( null , null , null ) ) . thenReturn ( java. util . Arrays . asList ( comprehensive ) ) ;
when ( service . trainingTaskClassConfigMapper . selectListByTeachingClass ( "class-1" , null ) ) . thenReturn ( Collections . emptyList ( ) ) ;
when ( service . trainingTaskClassConfigMapper . selectListByTeachingClass ( "class-1" , null ) ) . thenReturn ( Collections . emptyList ( ) ) ;
SchoolClass schoolClass = teachingClass ( "class-1" , "teacher-1" ) ;
SchoolClass schoolClass = teachingClass ( "class-1" , "teacher-1" ) ;
schoolClass . setSchoolId ( "school-1" ) ;
schoolClass . setSchoolId ( "school-1" ) ;
@ -911,7 +911,7 @@ class TrainingTaskServiceImplTest {
List < TrainingTask > result = service . listForTeachingClass ( "class-1" , true , teacher ) ;
List < TrainingTask > result = service . listForTeachingClass ( "class-1" , true , teacher ) ;
assertEquals ( List. of ( "comprehensive-case-training" ) , result . stream ( )
assertEquals ( java. util . Arrays . asList ( "comprehensive-case-training" ) , result . stream ( )
. map ( TrainingTask : : getTaskKey )
. map ( TrainingTask : : getTaskKey )
. collect ( java . util . stream . Collectors . toList ( ) ) ) ;
. collect ( java . util . stream . Collectors . toList ( ) ) ) ;
}
}