Commit f6b4653f authored by 王蔡翾's avatar 王蔡翾
Browse files

Merge remote-tracking branch 'origin/dev-v1.0' into dev-v1.0

parents 56d0958c 0f48de00
...@@ -5,16 +5,19 @@ import com.platform.business.model.dto.TheoreticalPracticeDTO; ...@@ -5,16 +5,19 @@ import com.platform.business.model.dto.TheoreticalPracticeDTO;
import com.platform.business.model.dto.TheoreticalPracticeStatisticsQueryDTO; import com.platform.business.model.dto.TheoreticalPracticeStatisticsQueryDTO;
import com.platform.business.model.entity.TheoreticalPracticeEntity; import com.platform.business.model.entity.TheoreticalPracticeEntity;
import com.platform.business.model.vo.TheoreticalPracticeKnowledgeStatisticsVO; import com.platform.business.model.vo.TheoreticalPracticeKnowledgeStatisticsVO;
import com.platform.business.model.vo.TheoreticalPracticeLevelOptionVO;
import com.platform.business.model.vo.TheoreticalPracticeStatisticsOverviewVO; import com.platform.business.model.vo.TheoreticalPracticeStatisticsOverviewVO;
import com.platform.business.model.vo.TheoreticalPracticeStudentStatisticsDetailVO; import com.platform.business.model.vo.TheoreticalPracticeStudentStatisticsDetailVO;
import com.platform.business.model.vo.TheoreticalPracticeStudentStatisticsVO; import com.platform.business.model.vo.TheoreticalPracticeStudentStatisticsVO;
import com.platform.business.model.vo.TheoreticalPracticeSummaryVO; import com.platform.business.model.vo.TheoreticalPracticeSummaryVO;
import com.platform.business.model.vo.TheoreticalPracticeVO;
import com.platform.exception.BusinessException; import com.platform.exception.BusinessException;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.ArgumentCaptor;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
...@@ -66,6 +69,64 @@ class TheoreticalPracticeServiceImplTest { ...@@ -66,6 +69,64 @@ class TheoreticalPracticeServiceImplTest {
assertThrows(BusinessException.class, () -> service.page(query)); assertThrows(BusinessException.class, () -> service.page(query));
} }
@Test
void levelOptionsShouldUseDedicatedFullPracticeLevelQuery() {
TheoreticalPracticeLevelOptionVO wastewater = levelOption("污水一级");
TheoreticalPracticeLevelOptionVO sludge = levelOption("污泥五级");
TheoreticalPracticeLevelOptionVO competition = levelOption("技能竞赛");
when(mapper.selectLevelOptions())
.thenReturn(Arrays.asList(competition, wastewater, sludge));
List<TheoreticalPracticeLevelOptionVO> options = service.levelOptions();
assertEquals(3, options.size());
assertEquals("技能竞赛", options.get(0).getValue());
assertEquals("污水一级", options.get(1).getLabel());
assertEquals("污泥五级", options.get(2).getValue());
verify(mapper).selectLevelOptions();
}
@Test
void pageShouldTrimLevelFilterReturnedByOptionsEndpoint() {
when(mapper.page(any(TheoreticalPracticeDTO.class), any(Date.class)))
.thenReturn(Collections.emptyList());
TheoreticalPracticeDTO query = new TheoreticalPracticeDTO();
query.setLev(" 污泥五级 ");
service.page(query);
ArgumentCaptor<TheoreticalPracticeDTO> captor =
ArgumentCaptor.forClass(TheoreticalPracticeDTO.class);
verify(mapper).page(captor.capture(), any(Date.class));
assertEquals("污泥五级", captor.getValue().getLev());
}
@Test
void pageShouldReturnProductDefinedThreeStateLabels() {
// 使用固定的远期和历史时间构造三种自然状态,避免测试依赖执行当天的日期。
Date past = new Date(946684800000L);
Date future = new Date(4102444800000L);
TheoreticalPracticeVO pending = practice(future, future, false);
TheoreticalPracticeVO ongoing = practice(past, future, false);
TheoreticalPracticeVO ended = practice(past, past, false);
TheoreticalPracticeVO manuallyClosed = practice(past, future, true);
when(mapper.page(any(TheoreticalPracticeDTO.class), any(Date.class)))
.thenReturn(Arrays.asList(pending, ongoing, ended, manuallyClosed));
List<TheoreticalPracticeVO> rows = service.page(new TheoreticalPracticeDTO());
assertEquals("未开始", rows.get(0).getStatus());
assertEquals("PENDING", rows.get(0).getStatusCode());
assertEquals("进行中", rows.get(1).getStatus());
assertEquals("ONGOING", rows.get(1).getStatusCode());
assertEquals("已结束", rows.get(2).getStatus());
assertEquals("ENDED", rows.get(2).getStatusCode());
// 手动关闭属于结束态,产品列表不再额外展示第四种状态。
assertEquals("已结束", rows.get(3).getStatus());
assertEquals("ENDED", rows.get(3).getStatusCode());
}
@Test @Test
void overviewShouldUseAllAssignedStudentsAndRoundRates() { void overviewShouldUseAllAssignedStudentsAndRoundRates() {
TheoreticalPracticeStatisticsOverviewVO raw = new TheoreticalPracticeStatisticsOverviewVO(); TheoreticalPracticeStatisticsOverviewVO raw = new TheoreticalPracticeStatisticsOverviewVO();
...@@ -167,4 +228,21 @@ class TheoreticalPracticeServiceImplTest { ...@@ -167,4 +228,21 @@ class TheoreticalPracticeServiceImplTest {
row.setStudyDurationSeconds(0L); row.setStudyDurationSeconds(0L);
return row; return row;
} }
/** 创建用于列表状态断言的最小理论练习对象。 */
private TheoreticalPracticeVO practice(Date startTime, Date endTime, boolean isClose) {
TheoreticalPracticeVO practice = new TheoreticalPracticeVO();
practice.setStartTime(startTime);
practice.setEndTime(endTime);
practice.setIsClose(isClose);
return practice;
}
/** 创建列表筛选接口使用的最小等级选项。 */
private TheoreticalPracticeLevelOptionVO levelOption(String level) {
TheoreticalPracticeLevelOptionVO option = new TheoreticalPracticeLevelOptionVO();
option.setValue(level);
option.setLabel(level);
return option;
}
} }
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