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
aaad0c6d
Commit
aaad0c6d
authored
Jul 17, 2017
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LogicalDeletePlugin 测试用例
parent
d180a47d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
125 additions
and
0 deletions
+125
-0
src/test/java/com/itfsw/mybatis/generator/plugins/LogicalDeletePluginTest.java
...sw/mybatis/generator/plugins/LogicalDeletePluginTest.java
+13
-0
src/test/resources/scripts/LogicalDeletePlugin/mybatis-generator-with-unconfig-logicalDeleteValue.xml
...in/mybatis-generator-with-unconfig-logicalDeleteValue.xml
+55
-0
src/test/resources/scripts/LogicalDeletePlugin/mybatis-generator-with-unfind-column.xml
...icalDeletePlugin/mybatis-generator-with-unfind-column.xml
+57
-0
No files found.
src/test/java/com/itfsw/mybatis/generator/plugins/LogicalDeletePluginTest.java
View file @
aaad0c6d
...
@@ -49,9 +49,22 @@ public class LogicalDeletePluginTest {
...
@@ -49,9 +49,22 @@ public class LogicalDeletePluginTest {
*/
*/
@Test
@Test
public
void
testWarnings
()
throws
IOException
,
XMLParserException
,
InvalidConfigurationException
,
InterruptedException
,
SQLException
{
public
void
testWarnings
()
throws
IOException
,
XMLParserException
,
InvalidConfigurationException
,
InterruptedException
,
SQLException
{
// 1. 不支持的类型
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/LogicalDeletePlugin/mybatis-generator-with-unsupport-type.xml"
);
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/LogicalDeletePlugin/mybatis-generator-with-unsupport-type.xml"
);
tool
.
generate
();
tool
.
generate
();
Assert
.
assertEquals
(
tool
.
getWarnings
().
get
(
0
),
"itfsw(逻辑删除插件):tb逻辑删除列(ts_2)的类型不在支持范围(请使用数字列,字符串列,布尔列)!"
);
Assert
.
assertEquals
(
tool
.
getWarnings
().
get
(
0
),
"itfsw(逻辑删除插件):tb逻辑删除列(ts_2)的类型不在支持范围(请使用数字列,字符串列,布尔列)!"
);
// 2. 没有找到配置的逻辑删除列
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/LogicalDeletePlugin/mybatis-generator-with-unfind-column.xml"
);
tool
.
generate
();
Assert
.
assertEquals
(
tool
.
getWarnings
().
get
(
0
),
"itfsw(逻辑删除插件):tb没有找到您配置的逻辑删除列(ts_999)!"
);
// 3. 没有配置逻辑删除值
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/LogicalDeletePlugin/mybatis-generator-with-unconfig-logicalDeleteValue.xml"
);
tool
.
generate
();
Assert
.
assertEquals
(
tool
.
getWarnings
().
get
(
0
),
"itfsw(逻辑删除插件):tb没有找到您配置的逻辑删除值,请全局或者局部配置logicalDeleteValue和logicalUnDeleteValue值!"
);
}
}
}
}
src/test/resources/scripts/LogicalDeletePlugin/mybatis-generator-with-unconfig-logicalDeleteValue.xml
0 → 100644
View file @
aaad0c6d
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2017.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<properties
resource=
"db.properties"
/>
<!--导入属性配置 -->
<context
id=
"default"
targetRuntime=
"MyBatis3"
>
<!-- 插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.LogicalDeletePlugin"
>
<property
name=
"logicalDeleteColumn"
value=
"del_flag"
/>
</plugin>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass=
"${driver}"
connectionURL=
"${url}"
userId=
"${username}"
password=
"${password}"
/>
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator
targetPackage=
""
targetProject=
""
>
<!-- 是否对model添加 构造函数 -->
<property
name=
"constructorBased"
value=
"true"
/>
<!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator
targetPackage=
""
targetProject=
""
/>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
""
targetProject=
""
type=
"XMLMAPPER"
/>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 要自动生成的表 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<table
tableName=
"tb"
>
<property
name=
"logicalDeleteColumn"
value=
"ts_1"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
src/test/resources/scripts/LogicalDeletePlugin/mybatis-generator-with-unfind-column.xml
0 → 100644
View file @
aaad0c6d
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2017.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<properties
resource=
"db.properties"
/>
<!--导入属性配置 -->
<context
id=
"default"
targetRuntime=
"MyBatis3"
>
<!-- 插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.LogicalDeletePlugin"
>
<property
name=
"logicalDeleteColumn"
value=
"del_flag"
/>
<property
name=
"logicalDeleteValue"
value=
"1"
/>
<property
name=
"logicalUnDeleteValue"
value=
"0"
/>
</plugin>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass=
"${driver}"
connectionURL=
"${url}"
userId=
"${username}"
password=
"${password}"
/>
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator
targetPackage=
""
targetProject=
""
>
<!-- 是否对model添加 构造函数 -->
<property
name=
"constructorBased"
value=
"true"
/>
<!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator
targetPackage=
""
targetProject=
""
/>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
""
targetProject=
""
type=
"XMLMAPPER"
/>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 要自动生成的表 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<table
tableName=
"tb"
>
<property
name=
"logicalDeleteColumn"
value=
"ts_999"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
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