Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mybatis-generator-plugin
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mybatis-generator-plugin
Commits
4790b363
Commit
4790b363
authored
Jul 07, 2017
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix:类命名规范不应该使用官方驼峰命名规则方法,而应采用简单进行首字母大写就行;
parent
6246cc63
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
src/test/java/com/itfsw/mybatis/generator/plugins/TableRenamePluginTest.java
...tfsw/mybatis/generator/plugins/TableRenamePluginTest.java
+33
-0
No files found.
src/test/java/com/itfsw/mybatis/generator/plugins/TableRenamePluginTest.java
View file @
4790b363
...
...
@@ -21,6 +21,8 @@ import com.itfsw.mybatis.generator.plugins.tools.MyBatisGeneratorTool;
import
org.junit.Assert
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.mybatis.generator.api.GeneratedJavaFile
;
import
org.mybatis.generator.api.MyBatisGenerator
;
import
org.mybatis.generator.exception.InvalidConfigurationException
;
import
org.mybatis.generator.exception.XMLParserException
;
...
...
@@ -60,4 +62,35 @@ public class TableRenamePluginTest {
tool
.
generate
();
Assert
.
assertEquals
(
tool
.
getWarnings
().
get
(
0
),
"itfsw:插件com.itfsw.mybatis.generator.plugins.TableRenamePlugin插件请不要配合table的domainObjectName或者mapperName一起使用!"
);
}
/**
* 测试具体生成
*/
@Test
public
void
testGenerate
()
throws
IOException
,
XMLParserException
,
InvalidConfigurationException
,
InterruptedException
,
SQLException
{
// 规则1 ^T 替换成 Test, 同时tb2 使用了tableOverride 替换成 TestOverride
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/TableRenamePlugin/mybatis-generator-rule1.xml"
);
MyBatisGenerator
myBatisGenerator
=
tool
.
generate
();
for
(
GeneratedJavaFile
file
:
myBatisGenerator
.
getGeneratedJavaFiles
()){
String
name
=
file
.
getCompilationUnit
().
getType
().
getShortName
();
if
(
name
.
matches
(
".*1.*"
)){
Assert
.
assertTrue
(
name
.
matches
(
"Testb1.*"
));
}
else
{
Assert
.
assertTrue
(
name
.
matches
(
"TestOverride.*"
));
}
}
}
/**
* 测试替代 TablePrefixPlugin 插件
*/
@Test
public
void
testGenerateLikeTablePrefixPlugin
()
throws
IOException
,
XMLParserException
,
InvalidConfigurationException
,
InterruptedException
,
SQLException
{
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/TableRenamePlugin/mybatis-generator-like-TablePrefixPlugin.xml"
);
MyBatisGenerator
myBatisGenerator
=
tool
.
generate
();
for
(
GeneratedJavaFile
file
:
myBatisGenerator
.
getGeneratedJavaFiles
()){
String
name
=
file
.
getCompilationUnit
().
getType
().
getShortName
();
Assert
.
assertTrue
(
name
.
matches
(
"DB1.*"
));
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment