Commit 4790b363 authored by hewei's avatar hewei

bugfix:类命名规范不应该使用官方驼峰命名规则方法,而应采用简单进行首字母大写就行;

parent 6246cc63
......@@ -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.*"));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment