You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.5 KiB
Java
36 lines
1.5 KiB
Java
|
2 months ago
|
package com.sztzjy.linkCommerce.controller.stu;
|
||
|
|
|
||
|
|
import com.sztzjy.linkCommerce.entity.SchoolClass;
|
||
|
|
import com.sztzjy.linkCommerce.mapper.SchoolClassMapper;
|
||
|
|
import com.sztzjy.linkCommerce.mapper.TaskAllocationMapper;
|
||
|
|
import com.sztzjy.linkCommerce.util.ResultEntity;
|
||
|
|
import org.junit.jupiter.api.Test;
|
||
|
|
import org.springframework.http.HttpStatus;
|
||
|
|
|
||
|
|
import java.util.Collections;
|
||
|
|
|
||
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||
|
|
import static org.mockito.Mockito.mock;
|
||
|
|
import static org.mockito.Mockito.never;
|
||
|
|
import static org.mockito.Mockito.verify;
|
||
|
|
import static org.mockito.Mockito.when;
|
||
|
|
|
||
|
|
class TaskAllocationControllerTest {
|
||
|
|
|
||
|
|
@Test
|
||
|
|
void teacherCannotUpdateTaskAllocationForClassCreatedByAnotherTeacher() {
|
||
|
|
TaskAllocationController controller = new TaskAllocationController();
|
||
|
|
controller.taskAllocationMapper = mock(TaskAllocationMapper.class);
|
||
|
|
controller.schoolClassMapper = mock(SchoolClassMapper.class);
|
||
|
|
SchoolClass schoolClass = new SchoolClass();
|
||
|
|
schoolClass.setSchoolClassId("class-1");
|
||
|
|
schoolClass.setCreatedBy("teacher-2");
|
||
|
|
when(controller.schoolClassMapper.selectByPrimaryKey("class-1")).thenReturn(schoolClass);
|
||
|
|
|
||
|
|
ResultEntity result = controller.updateTaskAllocationByClassId(Collections.emptyList(), "class-1", "school-1", "teacher-1");
|
||
|
|
|
||
|
|
assertEquals(HttpStatus.BAD_REQUEST, result.getStatusCode());
|
||
|
|
verify(controller.taskAllocationMapper, never()).deleteByExample(org.mockito.ArgumentMatchers.any());
|
||
|
|
}
|
||
|
|
}
|