add ConditionBuilder

This commit is contained in:
Looly
2020-09-18 11:27:26 +08:00
parent 75a6da5b5f
commit 5a73a17f4d
8 changed files with 217 additions and 49 deletions

View File

@@ -0,0 +1,21 @@
package cn.hutool.db.sql;
import org.junit.Assert;
import org.junit.Test;
public class ConditionBuilderTest {
@Test
public void buildTest(){
Condition c1 = new Condition("user", null);
Condition c2 = new Condition("name", "!= null");
c2.setLinkOperator(LogicalOperator.OR);
Condition c3 = new Condition("group", "like %aaa");
final ConditionBuilder builder = ConditionBuilder.of(c1, c2, c3);
final String sql = builder.build();
Assert.assertEquals("user IS NULL OR name IS NOT NULL AND group LIKE ?", sql);
Assert.assertEquals(1, builder.getParamValues().size());
Assert.assertEquals("%aaa", builder.getParamValues().get(0));
}
}