use of org.dbflute.twowaysql.context.CommandContext in project dbflute-core by dbflute.
the class BeginNodeTest method test_parse_BEGIN_that_has_nested_BEGIN_nest_and_adjustment.
public void test_parse_BEGIN_that_has_nested_BEGIN_nest_and_adjustment() {
// ## Arrange ##
String sql = "/*BEGIN*/where";
sql = sql + " ";
sql = sql + "/*IF pmb.memberName != null*/";
sql = sql + "FIXED";
sql = sql + "/*END*/";
sql = sql + " ";
sql = sql + "/*BEGIN*/";
sql = sql + "FIXED2 /*IF false*/and BBB/*END*/ /*IF true*/and CCC/*END*/";
sql = sql + "/*END*/";
sql = sql + "/*END*/";
SqlAnalyzer analyzer = new SqlAnalyzer(sql, false);
// ## Act ##
Node rootNode = analyzer.analyze();
// ## Assert ##
MockMemberPmb pmb = new MockMemberPmb();
pmb.setMemberName("foo");
CommandContext ctx = createCtx(pmb);
rootNode.accept(ctx);
log("ctx:" + ctx);
// Basically Unsupported!
assertEquals("where FIXED FIXED2 CCC", ctx.getSql());
}
use of org.dbflute.twowaysql.context.CommandContext in project dbflute-core by dbflute.
the class BeginNodeTest method test_parse_BEGIN_that_has_nested_BEGIN_toponly_false.
public void test_parse_BEGIN_that_has_nested_BEGIN_toponly_false() {
// ## Arrange ##
String sql = "/*BEGIN*/where";
sql = sql + " ";
sql = sql + "/*IF pmb.memberName != null*/";
sql = sql + "FIXED";
sql = sql + "/*END*/";
sql = sql + " ";
sql = sql + "/*BEGIN*/";
sql = sql + "FIXED2 /*IF true*/and BBB/*END*/ /*IF true*/and CCC/*END*/";
sql = sql + "/*END*/";
sql = sql + "/*END*/";
SqlAnalyzer analyzer = new SqlAnalyzer(sql, false);
// ## Act ##
Node rootNode = analyzer.analyze();
// ## Assert ##
MockMemberPmb pmb = new MockMemberPmb();
CommandContext ctx = createCtx(pmb);
rootNode.accept(ctx);
log("ctx:" + ctx);
assertEquals("where FIXED2 BBB and CCC", ctx.getSql());
}
use of org.dbflute.twowaysql.context.CommandContext in project dbflute-core by dbflute.
the class BeginNodeTest method test_parse_BEGIN_IF_notFoundProperty_with_parameterMap.
public void test_parse_BEGIN_IF_notFoundProperty_with_parameterMap() {
// ## Arrange ##
String sql = "/*BEGIN*/where";
sql = sql + " /*IF pmb.wrongMemberId != null*/member.MEMBER_ID = /*pmb.memberId*/3/*END*/";
sql = sql + " /*IF pmb.memberName != null*/and member.MEMBER_NAME like /*pmb.memberName*/'foo%'/*END*/";
sql = sql + "/*END*/";
SqlAnalyzer analyzer = new SqlAnalyzer(sql, false);
// ## Act ##
try {
MockPagingMemberPmb pmb = new MockPagingMemberPmb();
Node rootNode = analyzer.analyze();
CommandContext ctx = createCtx(pmb);
rootNode.accept(ctx);
// ## Assert ##
fail();
} catch (IfCommentNotFoundPropertyException e) {
// OK
log(e.getMessage());
}
}
use of org.dbflute.twowaysql.context.CommandContext in project dbflute-core by dbflute.
the class BeginNodeTest method test_parse_BEGIN_that_has_nested_IFIF_root_has_no_and.
public void test_parse_BEGIN_that_has_nested_IFIF_root_has_no_and() {
// ## Arrange ##
String sql = "/*BEGIN*/where";
sql = sql + " ";
sql = sql + "/*IF pmb.memberName != null*/";
sql = sql + "AAA /*IF true*/and BBB /*IF true*/and CCC/*END*//*END*/ /*IF true*/and DDD/*END*/";
sql = sql + "/*END*/";
sql = sql + "/*END*/";
SqlAnalyzer analyzer = new SqlAnalyzer(sql, false);
// ## Act ##
Node rootNode = analyzer.analyze();
// ## Assert ##
MockMemberPmb pmb = new MockMemberPmb();
pmb.setMemberName("foo");
CommandContext ctx = createCtx(pmb);
rootNode.accept(ctx);
log("ctx:" + ctx);
String expected = "where AAA and BBB and CCC and DDD";
assertEquals(expected, ctx.getSql());
}
use of org.dbflute.twowaysql.context.CommandContext in project dbflute-core by dbflute.
the class BeginNodeTest method test_parse_BEGIN_for_where_either_true_ln.
public void test_parse_BEGIN_for_where_either_true_ln() {
// ## Arrange ##
String sql = "/*BEGIN*/where" + ln();
sql = sql + " /*IF pmb.memberId != null*/" + ln();
sql = sql + " member.MEMBER_ID = 3" + ln();
sql = sql + " /*END*/" + ln();
sql = sql + " /*IF pmb.memberName != null*/" + ln();
sql = sql + " and member.MEMBER_NAME = 'TEST'" + ln();
sql = sql + " /*END*/" + ln();
sql = sql + "/*END*/";
SqlAnalyzer analyzer = new SqlAnalyzer(sql, false);
// ## Act ##
Node rootNode = analyzer.analyze();
// ## Assert ##
MockMemberPmb pmb = new MockMemberPmb();
pmb.setMemberName("pmb");
CommandContext ctx = createCtx(pmb);
rootNode.accept(ctx);
log("ctx:" + ctx);
String expected = "where" + ln() + " " + ln() + " member.MEMBER_NAME = 'TEST'" + ln() + " " + ln();
assertEquals(expected, ctx.getSql());
}
Aggregations