"...sms/service/git@gitlab.ruzhoukj.com:wujipeng/ops.git" did not exist on "85d08bdaec9ca3c229c98a5f5b95a9540c28a24b"
Commit 9648b914 authored by 王蔡翾's avatar 王蔡翾
Browse files

评议撤回无法重新发起bug修复

parent 3e48b362
...@@ -130,6 +130,40 @@ class EvaluationServiceImplTest { ...@@ -130,6 +130,40 @@ class EvaluationServiceImplTest {
verify(taskMapper).countNonRevokedBySubjectId(101); verify(taskMapper).countNonRevokedBySubjectId(101);
} }
@Test
void revokedTaskShouldAllowSameSubjectToBeCreatedAgain() {
EvaluationTaskEntity revokedTask = pendingTask();
when(taskMapper.expireDueTasks(any(Date.class))).thenReturn(0);
when(taskMapper.selectByIdForUpdate("T1")).thenReturn(revokedTask);
when(taskMapper.revokePending(eq("T1"), eq("A1"), any(Date.class))).thenReturn(1);
// 第一次任务撤回后仍保留为历史记录;重新发起时,防重查询必须忽略这条已撤回记录。
service.revoke("T1", "A1");
EvaluationTaskCreateDTO request = new EvaluationTaskCreateDTO();
request.setSubjectId(101);
Calendar deadline = Calendar.getInstance();
deadline.add(Calendar.DAY_OF_MONTH, 2);
request.setDeadline(new SimpleDateFormat("yyyy-MM-dd").format(deadline.getTime()));
when(classSubjectService.getById(101)).thenReturn(endedSubject);
when(taskMapper.countNonRevokedBySubjectId(101)).thenReturn(0);
when(taskMapper.selectActiveStudentIdsByClassId(10)).thenReturn(Collections.singletonList("S1"));
when(taskMapper.insert(any(EvaluationTaskEntity.class))).thenReturn(1);
when(recordMapper.batchInsert(any())).thenReturn(1);
when(notificationPublisher.publish(any(NotificationPublishDTO.class), eq("A1"), eq("管理员甲")))
.thenReturn("event-id");
EvaluationTaskVO newTask = new EvaluationTaskVO();
newTask.setId("T2");
when(taskMapper.selectTaskView(any())).thenReturn(newTask);
EvaluationTaskVO result = service.createTask(request, "A1", "管理员甲");
// 重新发起必须创建全新的任务及学员记录,不能恢复或覆盖已经撤回的历史任务。
assertEquals("T2", result.getId());
verify(taskMapper).insert(any(EvaluationTaskEntity.class));
verify(recordMapper).batchInsert(any());
}
@Test @Test
void submitShouldPersistScoresAndTryToCompleteTask() { void submitShouldPersistScoresAndTryToCompleteTask() {
EvaluationTaskEntity task = pendingTask(); EvaluationTaskEntity task = pendingTask();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment