From 7e3e6d79230b3299f679b82ae82cd556f7a58f9f Mon Sep 17 00:00:00 2001 From: wkc <978997012@qq.com> Date: Mon, 23 Mar 2026 15:54:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BE=81=E4=BF=A1=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E6=B5=8B=E8=AF=95=E5=9F=BA=E7=A1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ccdi-lsfx/pom.xml | 6 ++++ .../lsfx/client/CreditParseClientTest.java | 4 +++ .../controller/CreditParseControllerTest.java | 29 +++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 ccdi-lsfx/src/test/java/com/ruoyi/lsfx/client/CreditParseClientTest.java create mode 100644 ccdi-lsfx/src/test/java/com/ruoyi/lsfx/controller/CreditParseControllerTest.java diff --git a/ccdi-lsfx/pom.xml b/ccdi-lsfx/pom.xml index bf3f3ed3..2fac92c9 100644 --- a/ccdi-lsfx/pom.xml +++ b/ccdi-lsfx/pom.xml @@ -44,5 +44,11 @@ org.springdoc springdoc-openapi-starter-webmvc-ui + + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/ccdi-lsfx/src/test/java/com/ruoyi/lsfx/client/CreditParseClientTest.java b/ccdi-lsfx/src/test/java/com/ruoyi/lsfx/client/CreditParseClientTest.java new file mode 100644 index 00000000..565bdfa7 --- /dev/null +++ b/ccdi-lsfx/src/test/java/com/ruoyi/lsfx/client/CreditParseClientTest.java @@ -0,0 +1,4 @@ +package com.ruoyi.lsfx.client; + +class CreditParseClientTest { +} diff --git a/ccdi-lsfx/src/test/java/com/ruoyi/lsfx/controller/CreditParseControllerTest.java b/ccdi-lsfx/src/test/java/com/ruoyi/lsfx/controller/CreditParseControllerTest.java new file mode 100644 index 00000000..e1249ed5 --- /dev/null +++ b/ccdi-lsfx/src/test/java/com/ruoyi/lsfx/controller/CreditParseControllerTest.java @@ -0,0 +1,29 @@ +package com.ruoyi.lsfx.controller; + +import com.ruoyi.common.core.domain.AjaxResult; +import org.junit.jupiter.api.Test; +import org.springframework.mock.web.MockMultipartFile; + +import java.nio.charset.StandardCharsets; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class CreditParseControllerTest { + + private final CreditParseController controller = new CreditParseController(); + + @Test + void parse_shouldRejectEmptyFile() { + AjaxResult result = controller.parse(null, null, null); + assertEquals(500, result.get("code")); + } + + @Test + void parse_shouldRejectNonHtmlFile() { + MockMultipartFile file = new MockMultipartFile( + "file", "credit.pdf", "application/pdf", "x".getBytes(StandardCharsets.UTF_8) + ); + AjaxResult result = controller.parse(file, null, null); + assertEquals(500, result.get("code")); + } +}