Files
svn-log-tool/src/test/java/com/svnlog/web/service/AiInputValidatorTest.java
mangmang bdf6367404 feat(web): 增强任务治理与系统诊断能力
新增任务持久化、筛选分页、取消任务、健康检查与 AI 输入校验,并完善前端历史管理交互与容错重试机制。补充对应单元测试,提升系统稳定性和可运维性。
2026-03-08 23:35:36 +08:00

37 lines
1.3 KiB
Java

package com.svnlog.web.service;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class AiInputValidatorTest {
@Test
public void shouldRejectEmptyListWhenValidatingInputFiles() {
AiInputValidator validator = new AiInputValidator();
Assertions.assertThrows(IllegalArgumentException.class, () -> validator.validate(Collections.<Path>emptyList()));
}
@Test
public void shouldRejectNonMarkdownFileWhenValidatingInputFiles() throws Exception {
AiInputValidator validator = new AiInputValidator();
Path temp = Files.createTempFile("ai-input", ".txt");
Files.write(temp, "abc".getBytes(StandardCharsets.UTF_8));
Assertions.assertThrows(IllegalArgumentException.class, () -> validator.validate(Arrays.asList(temp)));
}
@Test
public void shouldAcceptSmallMarkdownFilesWhenValidatingInputFiles() throws Exception {
AiInputValidator validator = new AiInputValidator();
Path temp = Files.createTempFile("ai-input", ".md");
Files.write(temp, "# title".getBytes(StandardCharsets.UTF_8));
validator.validate(Arrays.asList(temp));
Assertions.assertTrue(true);
}
}