修复住宿:床位重叠冲突返回标准化业务错误码
This commit is contained in:
1 parent
fb5834bb1e
commit
eb1ddfcaa8
4 files changed
+66
-4
No files matched your search
+26
@@ -2,6 +2,7 @@ package com.ruoyi.web.controller.train;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -181,5 +182,30 @@ public class AccommodationAndAuthApiControllerContractTest
|
||||
(java.util.Map<String, Object>) controller.getCapabilities().get("data");
|
||||
assertEquals(Boolean.FALSE, missing.get("manualRevokeAvailable"));
|
||||
}
|
||||
|
||||
/**
|
||||
* EX-13: 床位时间窗口冲突必须返回标准业务错误码 (AccommodationErrorCode.BED_ALREADY_OCCUPIED = 40060),
|
||||
* 严禁退化为未处理的系统 500 异常。
|
||||
*/
|
||||
@Test
|
||||
public void testEx13_BedOverlapErrorResponseContract()
|
||||
{
|
||||
com.ruoyi.framework.web.exception.GlobalExceptionHandler handler =
|
||||
new com.ruoyi.framework.web.exception.GlobalExceptionHandler();
|
||||
|
||||
com.ruoyi.common.exception.ServiceException ex = new com.ruoyi.common.exception.ServiceException(
|
||||
"BED_ALREADY_OCCUPIED: 该床位在目标培训周期内已被占用 (宿舍: DORM_101,床位: 1号床)",
|
||||
com.ruoyi.train.constant.AccommodationErrorCode.BED_ALREADY_OCCUPIED);
|
||||
|
||||
com.ruoyi.common.core.domain.AjaxResult result = handler.handleServiceException(ex, null);
|
||||
assertNotNull(result);
|
||||
assertEquals("HTTP 响应体 code 必须是标准业务错误码 40060",
|
||||
Integer.valueOf(com.ruoyi.train.constant.AccommodationErrorCode.BED_ALREADY_OCCUPIED),
|
||||
result.get(com.ruoyi.common.core.domain.AjaxResult.CODE_TAG));
|
||||
assertTrue("响应体 code 严禁为系统 500 异常",
|
||||
!Integer.valueOf(500).equals(result.get(com.ruoyi.common.core.domain.AjaxResult.CODE_TAG)));
|
||||
assertTrue("响应体消息必须包含 BED_ALREADY_OCCUPIED 提示",
|
||||
String.valueOf(result.get(com.ruoyi.common.core.domain.AjaxResult.MSG_TAG)).contains("BED_ALREADY_OCCUPIED"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user