提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.infra.service.codegen.inner; |
H |
2 |
|
|
3 |
import com.iailab.module.infra.dal.dataobject.codegen.CodegenColumnDO; |
|
4 |
import com.iailab.module.infra.dal.dataobject.codegen.CodegenTableDO; |
|
5 |
import com.iailab.module.infra.enums.codegen.CodegenFrontTypeEnum; |
|
6 |
import com.iailab.module.infra.enums.codegen.CodegenTemplateTypeEnum; |
|
7 |
import org.junit.jupiter.api.Disabled; |
|
8 |
import org.junit.jupiter.api.Test; |
|
9 |
|
|
10 |
import java.util.Arrays; |
|
11 |
import java.util.List; |
|
12 |
import java.util.Map; |
|
13 |
|
|
14 |
/** |
|
15 |
* {@link CodegenEngine} 的 Vue2 + Element UI 单元测试 |
|
16 |
* |
|
17 |
* @author iailab |
|
18 |
*/ |
|
19 |
@Disabled |
|
20 |
public class CodegenEngineVue2Test extends CodegenEngineAbstractTest { |
|
21 |
|
|
22 |
@Test |
|
23 |
public void testExecute_vue2_one() { |
|
24 |
// 准备参数 |
|
25 |
CodegenTableDO table = getTable("student") |
|
26 |
.setFrontType(CodegenFrontTypeEnum.VUE2.getType()) |
|
27 |
.setTemplateType(CodegenTemplateTypeEnum.ONE.getType()); |
|
28 |
List<CodegenColumnDO> columns = getColumnList("student"); |
|
29 |
|
|
30 |
// 调用 |
|
31 |
Map<String, String> result = codegenEngine.execute(table, columns, null, null); |
|
32 |
// 生成测试文件 |
|
33 |
//writeResult(result, resourcesPath + "/vue2_one"); |
|
34 |
// 断言 |
|
35 |
assertResult(result, "/vue2_one"); |
|
36 |
} |
|
37 |
|
|
38 |
@Test |
|
39 |
public void testExecute_vue2_tree() { |
|
40 |
// 准备参数 |
|
41 |
CodegenTableDO table = getTable("category") |
|
42 |
.setFrontType(CodegenFrontTypeEnum.VUE2.getType()) |
|
43 |
.setTemplateType(CodegenTemplateTypeEnum.TREE.getType()); |
|
44 |
List<CodegenColumnDO> columns = getColumnList("category"); |
|
45 |
|
|
46 |
// 调用 |
|
47 |
Map<String, String> result = codegenEngine.execute(table, columns, null, null); |
|
48 |
// 生成测试文件 |
|
49 |
//writeResult(result, resourcesPath + "/vue2_tree"); |
|
50 |
// 断言 |
|
51 |
assertResult(result, "/vue2_tree"); |
|
52 |
// writeFile(result, "/Users/yunai/test/demo66.zip"); |
|
53 |
} |
|
54 |
|
|
55 |
@Test |
|
56 |
public void testExecute_vue2_master_normal() { |
|
57 |
testExecute_vue2_master(CodegenTemplateTypeEnum.MASTER_NORMAL, "/vue2_master_normal"); |
|
58 |
} |
|
59 |
|
|
60 |
@Test |
|
61 |
public void testExecute_vue2_master_erp() { |
|
62 |
testExecute_vue2_master(CodegenTemplateTypeEnum.MASTER_ERP, "/vue2_master_erp"); |
|
63 |
} |
|
64 |
|
|
65 |
@Test |
|
66 |
public void testExecute_vue2_master_inner() { |
|
67 |
testExecute_vue2_master(CodegenTemplateTypeEnum.MASTER_INNER, "/vue2_master_inner"); |
|
68 |
} |
|
69 |
|
|
70 |
private void testExecute_vue2_master(CodegenTemplateTypeEnum templateType, |
|
71 |
String path) { |
|
72 |
// 准备参数 |
|
73 |
CodegenTableDO table = getTable("student") |
|
74 |
.setFrontType(CodegenFrontTypeEnum.VUE2.getType()) |
|
75 |
.setTemplateType(templateType.getType()); |
|
76 |
List<CodegenColumnDO> columns = getColumnList("student"); |
|
77 |
// 准备参数(子表) |
|
78 |
CodegenTableDO contactTable = getTable("contact") |
|
79 |
.setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) |
|
80 |
.setFrontType(CodegenFrontTypeEnum.VUE2.getType()) |
|
81 |
.setSubJoinColumnId(100L).setSubJoinMany(true); |
|
82 |
List<CodegenColumnDO> contactColumns = getColumnList("contact"); |
|
83 |
// 准备参数(班主任) |
|
84 |
CodegenTableDO teacherTable = getTable("teacher") |
|
85 |
.setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) |
|
86 |
.setFrontType(CodegenFrontTypeEnum.VUE2.getType()) |
|
87 |
.setSubJoinColumnId(200L).setSubJoinMany(false); |
|
88 |
List<CodegenColumnDO> teacherColumns = getColumnList("teacher"); |
|
89 |
|
|
90 |
// 调用 |
|
91 |
Map<String, String> result = codegenEngine.execute(table, columns, |
|
92 |
Arrays.asList(contactTable, teacherTable), Arrays.asList(contactColumns, teacherColumns)); |
|
93 |
// 生成测试文件 |
|
94 |
//writeResult(result, resourcesPath + path); |
|
95 |
// 断言 |
|
96 |
assertResult(result, path); |
|
97 |
// writeFile(result, "/Users/yunai/test/demo11.zip"); |
|
98 |
} |
|
99 |
|
|
100 |
} |