| | |
| | | } |
| | | |
| | | @Test |
| | | void deleteShouldRejectMismatchedTestAndReceptionStates() |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setTestStatus("RUNNING"); |
| | | current.setReceptionStatus("NOT_STARTED"); |
| | | when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current); |
| | | |
| | | ServiceException exception = assertThrows(ServiceException.class, |
| | | () -> testService.deleteTestByIds(new Long[] { 10L }, 7L, "operator")); |
| | | |
| | | assertEquals("开始接收后不能删除测试", exception.getMessage()); |
| | | verify(testMapper, never()).deleteTestById(anyLong(), any(String.class)); |
| | | } |
| | | |
| | | @Test |
| | | void startReceptionShouldPersistReceptionWithoutLegacyIntervals() |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setTestStatus("WAITING"); |
| | | current.setReceptionStatus("NOT_STARTED"); |
| | | current.getBatteries().get(0).getBinding().setBindingId(30L); |
| | | when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current); |
| | |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setTestStatus("WAITING"); |
| | | current.setReceptionStatus("NOT_STARTED"); |
| | | current.getBatteries().get(0).getBinding().setBindingId(30L); |
| | | when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current); |
| | |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setTestStatus("WAITING"); |
| | | current.setReceptionStatus("NOT_STARTED"); |
| | | current.getBatteries().get(0).getBinding().setBindingId(30L); |
| | | when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current); |
| | |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setTestStatus("WAITING"); |
| | | current.setReceptionStatus("NOT_STARTED"); |
| | | current.getBatteries().get(0).getBinding().setBindingId(30L); |
| | | when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current); |
| | |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setTestStatus("WAITING"); |
| | | current.setReceptionStatus("NOT_STARTED"); |
| | | current.getBatteries().get(0).getBinding().setBindingId(30L); |
| | | when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current); |
| | |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setTestStatus("WAITING"); |
| | | current.setReceptionStatus("NOT_STARTED"); |
| | | current.getBatteries().get(0).getBinding().setBindingId(30L); |
| | | current.getBatteries().get(0).setCollectorChannels(Collections.emptyList()); |
| | |
| | | } |
| | | |
| | | @Test |
| | | void startReceptionShouldRejectMismatchedTestAndReceptionStates() |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setTestStatus("COMPLETED"); |
| | | current.setReceptionStatus("NOT_STARTED"); |
| | | when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current); |
| | | |
| | | ServiceException exception = assertThrows(ServiceException.class, |
| | | () -> testService.startReception(10L, 7L, "operator")); |
| | | |
| | | assertEquals("当前测试不是未开始接收状态", exception.getMessage()); |
| | | verify(testMapper, never()).updateReceptionStarted(any(), any(), anyBoolean(), any()); |
| | | } |
| | | |
| | | @Test |
| | | void pauseReceptionShouldRejectMismatchedTestAndReceptionStates() |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setTestStatus("PAUSED"); |
| | | current.setReceptionStatus("RECEIVING"); |
| | | when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current); |
| | | |
| | | ServiceException exception = assertThrows(ServiceException.class, |
| | | () -> testService.pauseReception(10L, 7L, "operator")); |
| | | |
| | | assertEquals("当前测试不是接收中状态", exception.getMessage()); |
| | | verify(testMapper, never()).updateReceptionPaused(any(), any(), any()); |
| | | } |
| | | |
| | | @Test |
| | | void pauseReceptionShouldStopPollingAndAppendAudit() |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setTestStatus("RUNNING"); |
| | | current.setReceptionStatus("RECEIVING"); |
| | | when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current); |
| | | when(testMapper.updateReceptionPaused(eq(10L), eq("operator"), any())).thenReturn(1); |
| | |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setTestStatus("PAUSED"); |
| | | current.setReceptionStatus("PAUSED"); |
| | | List<TTestBattery> configuredBatteries = current.getBatteries(); |
| | | current.setBatteries(null); |
| | |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setTestStatus("PAUSED"); |
| | | current.setReceptionStatus("PAUSED"); |
| | | when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current); |
| | | when(testMapper.updateReceptionStopped(eq(10L), eq("operator"), any())).thenReturn(1); |
| | |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setTestStatus("RUNNING"); |
| | | current.setReceptionStatus("RECEIVING"); |
| | | when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current); |
| | | when(testMapper.updateReceptionStopped(eq(10L), eq("operator"), any())).thenReturn(1); |
| | |
| | | test.setPrincipalId(9L); |
| | | test.setTestTypeId(3L); |
| | | test.setTestPurpose("验证低温循环性能"); |
| | | test.setTestStatus("WAITING"); |
| | | test.setReceptionStatus("NOT_STARTED"); |
| | | test.setMonitorTimeoutMinutes(30); |
| | | test.setBatteries(Collections.singletonList(validBattery("BAT-001", 1L, 100L))); |
| | | test.setPlanSteps(Collections.singletonList(step)); |