DaoMapper 测试类新增 IN、NOT IN 测试方法
This commit is contained in:
@@ -7,8 +7,6 @@ import org.springframework.boot.SpringApplication;
|
|||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
|
|
||||||
import com.jeesite.common.io.PropertiesUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JeeSite Web
|
* JeeSite Web
|
||||||
* @author ThinkGem
|
* @author ThinkGem
|
||||||
@@ -19,9 +17,7 @@ import com.jeesite.common.io.PropertiesUtils;
|
|||||||
public class ApplicationTest {
|
public class ApplicationTest {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication app = new SpringApplication(ApplicationTest.class);
|
SpringApplication.run(ApplicationTest.class, args);
|
||||||
app.setDefaultProperties(PropertiesUtils.getInstance().getProperties());
|
|
||||||
app.run(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -164,6 +164,20 @@ public class DaoMapperTest extends BaseSpringContextTests {
|
|||||||
b = "a.id = #{sqlMap.where#id#EQ1} AND a.name LIKE #{sqlMap.where.name#LIKE1.val}";
|
b = "a.id = #{sqlMap.where#id#EQ1} AND a.name LIKE #{sqlMap.where.name#LIKE1.val}";
|
||||||
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
|
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
|
||||||
|
|
||||||
|
System.out.println("============ IN、NOT IN 测试 ============");
|
||||||
|
a = new Config("1").getSqlMap().getWhere()
|
||||||
|
.and("name", QueryType.IN, new String[]{"abc","def"})
|
||||||
|
.and("name2", QueryType.NOT_IN, ListUtils.newArrayList("abc","def")).toSql();
|
||||||
|
b = "a.id = #{sqlMap.where#id#EQ1} AND a.name IN ( #{sqlMap.where.name#IN1.val[0]}, #{sqlMap.where.name#IN1.val[1]} )"
|
||||||
|
+ " AND a.name2 NOT IN ( #{sqlMap.where.name2#NOT_IN1.val[0]}, #{sqlMap.where.name2#NOT_IN1.val[1]} )";
|
||||||
|
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
|
||||||
|
|
||||||
|
a = new Config("1").getSqlMap().getWhere()
|
||||||
|
.and("name", QueryType.IN, null).and("name2", QueryType.IN, new String[]{})
|
||||||
|
.and("name3", QueryType.NOT_IN, ListUtils.newArrayList()).toSql();
|
||||||
|
b = "a.id = #{sqlMap.where#id#EQ1}";
|
||||||
|
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
|
||||||
|
|
||||||
System.out.println("============ 带括号测试 ============");
|
System.out.println("============ 带括号测试 ============");
|
||||||
a = new Config("1").getSqlMap().getWhere()
|
a = new Config("1").getSqlMap().getWhere()
|
||||||
.andBracket("name", QueryType.EQ, "abc", 1).or("name", QueryType.EQ, "def", 2)
|
.andBracket("name", QueryType.EQ, "abc", 1).or("name", QueryType.EQ, "def", 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user