mirror of
https://github.com/ZSCNetSupportDept/WechatTicketSystem.git
synced 2025-10-28 23:55:04 +08:00
cortana test
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package love.sola.netsupport.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -15,19 +16,27 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class Cortana {
|
||||
|
||||
|
||||
public static List<Compiled> entries;
|
||||
|
||||
public static void load() {
|
||||
InputStream in = Lang.class.getClassLoader().getResourceAsStream("cortana.yml");
|
||||
Map<String, Object> root = (Map<String, Object>) new Yaml().load(in);
|
||||
|
||||
RawConfig root = new Yaml().loadAs(in, RawConfig.class);
|
||||
}
|
||||
|
||||
|
||||
public static class Compiled {
|
||||
static class Compiled {
|
||||
Pattern[] patterns;
|
||||
String[] replies;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Rule {
|
||||
String[] regexp;
|
||||
String[] replies;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class RawConfig {
|
||||
Map<String, Rule> rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
18
src/test/java/love/sola/netsupport/config/CortanaTest.java
Normal file
18
src/test/java/love/sola/netsupport/config/CortanaTest.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package love.sola.netsupport.config;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2016/4/18.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
*/
|
||||
public class CortanaTest {
|
||||
|
||||
@Test
|
||||
public void load() throws Exception {
|
||||
Cortana.load();
|
||||
}
|
||||
|
||||
}
|
||||
16
src/test/resources/cortana.yml
Normal file
16
src/test/resources/cortana.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
rules:
|
||||
rule1:
|
||||
regexp:
|
||||
- 'single test'
|
||||
replies:
|
||||
- 'single test'
|
||||
rule2:
|
||||
regexp: ['inline test', 'inline test']
|
||||
replies: ['inline test', 'inline test']
|
||||
rule3:
|
||||
regexp:
|
||||
- 'multi line test'
|
||||
- 'multi line test'
|
||||
replies:
|
||||
- 'multi line test'
|
||||
- 'multi line test'
|
||||
Reference in New Issue
Block a user