DaoMapper 测试类新增 IN、NOT IN 测试方法

This commit is contained in:
thinkgem
2019-08-02 16:53:05 +08:00
parent 2fe4f2e0e3
commit 7b599405fa
2 changed files with 18 additions and 8 deletions

View File

@@ -7,8 +7,6 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.test.context.ActiveProfiles;
import com.jeesite.common.io.PropertiesUtils;
/**
* JeeSite Web
* @author ThinkGem
@@ -19,9 +17,7 @@ import com.jeesite.common.io.PropertiesUtils;
public class ApplicationTest {
public static void main(String[] args) {
SpringApplication app = new SpringApplication(ApplicationTest.class);
app.setDefaultProperties(PropertiesUtils.getInstance().getProperties());
app.run(args);
SpringApplication.run(ApplicationTest.class, args);
}
}

View File

@@ -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}";
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("============ 带括号测试 ============");
a = new Config("1").getSqlMap().getWhere()
.andBracket("name", QueryType.EQ, "abc", 1).or("name", QueryType.EQ, "def", 2)