mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-30 06:37:36 +00:00
[Update] Core 提升 JsonFrameworkDescriptorSerializerTest 测试覆盖率至 100%;
[Update] JsonFrameworkDescriptorSerializerTest 提升测试覆盖率; [Add] badBotCode-MissingPatternsField-framework.json, badBotCode-PatternsFieldNonArray-framework.json 添加两种错误解析数据; [Change] test-framework.json 调整解析数据以检查两种软错误解析情况;
This commit is contained in:
parent
789c86406c
commit
4b97bf5803
@ -74,6 +74,8 @@ public class JsonFrameworkDescriptorSerializerTest {
|
|||||||
List<PluginDependency> expectedDependency = new ArrayList<>();
|
List<PluginDependency> expectedDependency = new ArrayList<>();
|
||||||
expectedDependency.add(new PluginDependency("RequireDepend@1.0.0"));
|
expectedDependency.add(new PluginDependency("RequireDepend@1.0.0"));
|
||||||
expectedDependency.add(new PluginDependency("OptionalDepend?@1.0.0"));
|
expectedDependency.add(new PluginDependency("OptionalDepend?@1.0.0"));
|
||||||
|
expectedDependency.add(new PluginDependency("AllVersionSupportedDependA"));
|
||||||
|
expectedDependency.add(new PluginDependency("AllVersionSupportedDependB@*"));
|
||||||
|
|
||||||
Assert.assertEquals(expectedDependency, descriptor.getDependencies());
|
Assert.assertEquals(expectedDependency, descriptor.getDependencies());
|
||||||
|
|
||||||
@ -82,6 +84,8 @@ public class JsonFrameworkDescriptorSerializerTest {
|
|||||||
|
|
||||||
List<Author> expectedAuthors = new ArrayList<>();
|
List<Author> expectedAuthors = new ArrayList<>();
|
||||||
expectedAuthors.add(new Author("LamGC", "https://github.com/LamGC", "lam827@lamgc.net"));
|
expectedAuthors.add(new Author("LamGC", "https://github.com/LamGC", "lam827@lamgc.net"));
|
||||||
|
expectedAuthors.add(new Author("UserA"));
|
||||||
|
expectedAuthors.add(new Author("UserB"));
|
||||||
|
|
||||||
Assert.assertEquals(expectedAuthors, descriptor.getAuthors());
|
Assert.assertEquals(expectedAuthors, descriptor.getAuthors());
|
||||||
|
|
||||||
@ -125,6 +129,24 @@ public class JsonFrameworkDescriptorSerializerTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void botCode_MissingPatternsTest() throws IOException {
|
||||||
|
try (Reader resourceReader = getResourceAsReader("badBotCode-MissingPatternsField-framework.json")) {
|
||||||
|
List<Pattern> patterns = gson.fromJson(resourceReader, DefaultFrameworkDescriptor.class)
|
||||||
|
.getBotCodeDescriptor().getPatterns();
|
||||||
|
Assert.assertTrue(patterns.isEmpty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void botCode_PatternsFieldNonArrayTest() throws IOException {
|
||||||
|
try (Reader resourceReader = getResourceAsReader("badBotCode-PatternsFieldNonArray-framework.json")) {
|
||||||
|
List<Pattern> patterns = gson.fromJson(resourceReader, DefaultFrameworkDescriptor.class)
|
||||||
|
.getBotCodeDescriptor().getPatterns();
|
||||||
|
Assert.assertTrue(patterns.isEmpty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test(expected = JsonParseException.class)
|
@Test(expected = JsonParseException.class)
|
||||||
public void platform_NonAObjectTest() throws IOException {
|
public void platform_NonAObjectTest() throws IOException {
|
||||||
try (Reader resourceReader = getResourceAsReader("badPlatform-NonObject-framework.json")) {
|
try (Reader resourceReader = getResourceAsReader("badPlatform-NonObject-framework.json")) {
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
// 该文件为 framework.json 格式完整示例, 非测试用文件.
|
||||||
|
{
|
||||||
|
"id": "cgj-mirai",
|
||||||
|
"description": "test",
|
||||||
|
"version": "3.0.0-alpha",
|
||||||
|
"requiresVersion": "=>3.0.0",
|
||||||
|
"provider": "Github@LamGC, Github@mamoe",
|
||||||
|
"license": "AGPL-3.0",
|
||||||
|
"frameworkClass": "com.example.FrameworkMain",
|
||||||
|
"dependencies": [
|
||||||
|
"RequireDepend@1.0.0",
|
||||||
|
"OptionalDepend?@1.0.0"
|
||||||
|
],
|
||||||
|
|
||||||
|
"platform": {
|
||||||
|
"name": "Tencent QQ",
|
||||||
|
"identify": "qq"
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "LamGC",
|
||||||
|
"url": "https://github.com/LamGC",
|
||||||
|
"email": "lam827@lamgc.net"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"botCode": {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
// 该文件为 framework.json 格式完整示例, 非测试用文件.
|
||||||
|
{
|
||||||
|
"id": "cgj-mirai",
|
||||||
|
"description": "test",
|
||||||
|
"version": "3.0.0-alpha",
|
||||||
|
"requiresVersion": "=>3.0.0",
|
||||||
|
"provider": "Github@LamGC, Github@mamoe",
|
||||||
|
"license": "AGPL-3.0",
|
||||||
|
"frameworkClass": "com.example.FrameworkMain",
|
||||||
|
"dependencies": [
|
||||||
|
"RequireDepend@1.0.0",
|
||||||
|
"OptionalDepend?@1.0.0"
|
||||||
|
],
|
||||||
|
|
||||||
|
"platform": {
|
||||||
|
"name": "Tencent QQ",
|
||||||
|
"identify": "qq"
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "LamGC",
|
||||||
|
"url": "https://github.com/LamGC",
|
||||||
|
"email": "lam827@lamgc.net"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"botCode": {
|
||||||
|
"patterns": {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,9 @@
|
|||||||
"frameworkClass": "com.example.FrameworkMain",
|
"frameworkClass": "com.example.FrameworkMain",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"RequireDepend@1.0.0",
|
"RequireDepend@1.0.0",
|
||||||
"OptionalDepend?@1.0.0"
|
"OptionalDepend?@1.0.0",
|
||||||
|
"AllVersionSupportedDependA",
|
||||||
|
"AllVersionSupportedDependB@*"
|
||||||
],
|
],
|
||||||
|
|
||||||
"platform": {
|
"platform": {
|
||||||
@ -20,6 +22,14 @@
|
|||||||
"name": "LamGC",
|
"name": "LamGC",
|
||||||
"url": "https://github.com/LamGC",
|
"url": "https://github.com/LamGC",
|
||||||
"email": "lam827@lamgc.net"
|
"email": "lam827@lamgc.net"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "UserA",
|
||||||
|
"url": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "UserB",
|
||||||
|
"email": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"botCode": {
|
"botCode": {
|
||||||
|
Loading…
Reference in New Issue
Block a user