From 34981c30a78e8bbd7791131059a9210f9928b62c Mon Sep 17 00:00:00 2001
From: 刘光辉 <347230014@qq.com>
Date: 星期四, 17 九月 2026 09:24:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master
---
jnpf-eln/jnpf-eln-controller/src/test/java/jnpf/elnController/ElnDianziJiluMubanControllerTest.java | 73 ++++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/jnpf-eln/jnpf-eln-controller/src/test/java/jnpf/elnController/ElnDianziJiluMubanControllerTest.java b/jnpf-eln/jnpf-eln-controller/src/test/java/jnpf/elnController/ElnDianziJiluMubanControllerTest.java
new file mode 100644
index 0000000..5f021ba
--- /dev/null
+++ b/jnpf-eln/jnpf-eln-controller/src/test/java/jnpf/elnController/ElnDianziJiluMubanControllerTest.java
@@ -0,0 +1,73 @@
+package jnpf.elnController;
+
+import jnpf.base.ActionResult;
+import jnpf.elnEntity.ElnMubanFileVo;
+import jnpf.util.context.SpringContext;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.context.support.StaticApplicationContext;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.lang.reflect.Method;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ElnDianziJiluMubanControllerTest {
+
+ @BeforeClass
+ public static void setUpSpringContext() {
+ SpringContext.setApplicationContext(new StaticApplicationContext());
+ }
+
+ @Test
+ public void exposesPinyinPathAndParameter() throws Exception {
+ RequestMapping requestMapping = ElnDianziJiluMubanController.class.getAnnotation(RequestMapping.class);
+ Method method = ElnDianziJiluMubanController.class.getMethod("file", String.class);
+ GetMapping getMapping = method.getAnnotation(GetMapping.class);
+ RequestParam requestParam = method.getParameters()[0].getAnnotation(RequestParam.class);
+
+ assertEquals("/dianzi_jilu_muban", requestMapping.value()[0]);
+ assertEquals("/file", getMapping.value()[0]);
+ assertEquals("jianyan_xiangmu", requestParam.value());
+ }
+
+ @Test
+ public void rejectsMissingInspectionItem() {
+ ElnDianziJiluMubanController controller = new ElnDianziJiluMubanController(
+ item -> { throw new AssertionError("鍙傛暟鏃犳晥鏃朵笉搴旇皟鐢� Service"); });
+
+ assertEquals(Integer.valueOf(400), controller.file(null).getCode());
+ assertEquals(Integer.valueOf(400), controller.file(" ").getCode());
+ }
+
+ @Test
+ public void returnsFileAndTrimsInspectionItem() {
+ AtomicReference<String> item = new AtomicReference<>();
+ ElnMubanFileVo file = new ElnMubanFileVo();
+ file.setFileId("file-1.docx");
+ ElnDianziJiluMubanController controller = new ElnDianziJiluMubanController(value -> {
+ item.set(value);
+ return file;
+ });
+
+ ActionResult<ElnMubanFileVo> result = controller.file(" item-1 ");
+
+ assertEquals(Integer.valueOf(200), result.getCode());
+ assertEquals("item-1", item.get());
+ assertEquals("file-1.docx", result.getData().getFileId());
+ }
+
+ @Test
+ public void returnsSuccessWithNullDataWhenTemplateMissing() {
+ ElnDianziJiluMubanController controller = new ElnDianziJiluMubanController(item -> null);
+
+ ActionResult<ElnMubanFileVo> result = controller.file("item-1");
+
+ assertEquals(Integer.valueOf(200), result.getCode());
+ assertNull(result.getData());
+ }
+}
--
Gitblit v1.8.0