feat(device): add DeepSeek command parsing and smoke tests
This commit is contained in:
1 parent
2499fcca91
commit
08fb43784b
5 files changed
+206
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package com.youlai.boot.device.ai;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class DeepSeekCommandServiceTest {
|
||||
@Test void acceptsSupportedCommands() {
|
||||
assertEquals(new AiCommand("WECHAT_VIDEO", "女儿"),
|
||||
DeepSeekCommandService.decode("{\"action\":\"WECHAT_VIDEO\",\"target\":\"女儿\"}"));
|
||||
assertEquals("WIFI", DeepSeekCommandService.decode(
|
||||
"{\"action\":\"OPEN_SETTINGS\",\"target\":\"WIFI\"}").target());
|
||||
}
|
||||
|
||||
@Test void rejectsUnsafeMalformedAndIncompleteCommands() {
|
||||
for (String input : new String[] {"", "{}", "null", "[]",
|
||||
"{\"action\":\"SHELL\",\"target\":\"reboot\"}",
|
||||
"{\"action\":\"WECHAT_VIDEO\",\"target\":\" \"}",
|
||||
"{\"action\":\"OPEN_SETTINGS\",\"target\":\"INSTALL\"}",
|
||||
"{\"action\":\"OPEN_APP\",\"target\":123}",
|
||||
"{\"action\":\"OPEN_APP\",\"target\":\"微信\",\"shell\":\"reboot\"}"}) {
|
||||
assertThrows(Exception.class, () -> DeepSeekCommandService.decode(input), input);
|
||||
}
|
||||
}
|
||||
|
||||
@Test void missingKeyFailsWithoutNetwork() {
|
||||
assertThrows(IllegalStateException.class, () -> new DeepSeekCommandService("", "deepseek-flash").parse("打开微信"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user