30 lines
896 B
Java
30 lines
896 B
Java
|
|
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"));
|
||
|
|
}
|
||
|
|
}
|