|
|
|
@ -2,9 +2,9 @@ package com.ibeetl.jlw.web;
|
|
|
|
|
|
|
|
|
|
import base.BaseTest;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import com.ibeetl.jlw.dao.ResourcesQuestionSnapshotDao;
|
|
|
|
|
import com.ibeetl.jlw.entity.ResourcesQuestionSnapshot;
|
|
|
|
|
import com.ibeetl.jlw.enums.TeacherOpenCourseQuestionFromTypeEnum;
|
|
|
|
|
import com.ibeetl.admin.test.util.test.TestEnvUtil;
|
|
|
|
|
import com.ibeetl.jlw.dao.TeacherOpenCourseQuestionLogDao;
|
|
|
|
|
import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionLog;
|
|
|
|
|
import org.junit.Assert;
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
@ -16,7 +16,6 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static com.ibeetl.admin.test.util.test.RandomUtils.randomSet;
|
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -34,31 +33,32 @@ class ResourcesQuestionSnapshotControllerTest extends BaseTest {
|
|
|
|
|
private static final String API = "/api/resourcesQuestionSnapshot";
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
ResourcesQuestionSnapshotDao resourcesQuestionSnapshotDao;
|
|
|
|
|
TeacherOpenCourseQuestionLogDao teacherOpenCourseQuestionLogDao;
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void getScoreInfo() throws Exception {
|
|
|
|
|
// 获取一个状态正常的作业ID
|
|
|
|
|
|
|
|
|
|
ResourcesQuestionSnapshot entity = new ResourcesQuestionSnapshot();
|
|
|
|
|
entity.setQuestionStatus(1);
|
|
|
|
|
List<ResourcesQuestionSnapshot> homeworkList = resourcesQuestionSnapshotDao.template(entity);
|
|
|
|
|
try {
|
|
|
|
|
TeacherOpenCourseQuestionLog entity = new TeacherOpenCourseQuestionLog();
|
|
|
|
|
entity.setTeacherOpenCourseQuestionLogStatus(1);
|
|
|
|
|
List<TeacherOpenCourseQuestionLog> questionLogs = teacherOpenCourseQuestionLogDao.template(entity);
|
|
|
|
|
// 断言
|
|
|
|
|
Assert.assertTrue(ObjectUtil.isNotEmpty(homeworkList));
|
|
|
|
|
Assert.assertTrue(ObjectUtil.isNotEmpty(questionLogs));
|
|
|
|
|
|
|
|
|
|
// 随机取一个学生的登录信息
|
|
|
|
|
putEnvLoginInfoStudent();
|
|
|
|
|
// 取第一个
|
|
|
|
|
TeacherOpenCourseQuestionLog questionLog = CollectionUtils.firstElement(questionLogs);
|
|
|
|
|
|
|
|
|
|
// 随机来源类型
|
|
|
|
|
TeacherOpenCourseQuestionFromTypeEnum fromTypeEnum = CollectionUtils
|
|
|
|
|
.firstElement(randomSet(TeacherOpenCourseQuestionFromTypeEnum.class));
|
|
|
|
|
// 模拟登录学生身份
|
|
|
|
|
TestEnvUtil.setProperty("user.id", questionLog.getUserId().toString());
|
|
|
|
|
TestEnvUtil.setProperty("user.orgId", questionLog.getOrgId().toString());
|
|
|
|
|
|
|
|
|
|
// 随机取一个学生的登录信息
|
|
|
|
|
putStudentLoginInfoToEnv();
|
|
|
|
|
|
|
|
|
|
//构造请求参数
|
|
|
|
|
RequestBuilder rb = MockMvcRequestBuilders.post(MODEL + "/getScoreInfo.json")
|
|
|
|
|
.contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
|
|
|
|
.param("fromType", fromTypeEnum.name())
|
|
|
|
|
// TODO 这里需要修改灵活的来源ID
|
|
|
|
|
.param("fromId", fromTypeEnum.name())
|
|
|
|
|
.param("fromType", questionLog.getTeacherOpenCourseQuestionLogFromType().toString())
|
|
|
|
|
.param("fromId", questionLog.getTeacherOpenCourseQuestionLogFromId().toString())
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
//发送请求,验证返回结果
|
|
|
|
@ -67,9 +67,12 @@ class ResourcesQuestionSnapshotControllerTest extends BaseTest {
|
|
|
|
|
.andExpect(MockMvcResultMatchers.jsonPath("$.code").value("0"))
|
|
|
|
|
.andReturn().getResponse().getContentAsString();
|
|
|
|
|
|
|
|
|
|
// 换回去原始的登录方式
|
|
|
|
|
clearEnvLoginInfo();
|
|
|
|
|
|
|
|
|
|
System.out.println(result);
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
throw e;
|
|
|
|
|
}finally {
|
|
|
|
|
// 清除登录信息
|
|
|
|
|
clearEnvLoginInfo();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|