use of org.dbflute.twowaysql.exception.EndCommentNotFoundException in project dbflute-core by dbflute.
the class ForNodeTest method test_accept_endNotFound.
// ===================================================================================
// Exception
// =========
public void test_accept_endNotFound() throws Exception {
// ## Arrange ##
MockPmb pmb = new MockPmb();
pmb.setMemberNameList(DfCollectionUtil.newArrayList("foo", "bar", "baz"));
pmb.setMemberNameListInternalLikeSearchOption(new LikeSearchOption().likeContain());
pmb.setMemberAccountList(DfCollectionUtil.newArrayList("ab%c", "%def"));
StringBuilder sb = new StringBuilder();
sb.append("select * from MEMBER").append(ln());
sb.append(" /*FOR pmb.memberNameList*//*FIRST*/and (/*END*/").append(ln());
sb.append(" /*NEXT 'or '*/MEMBER_NAME like /*#current*/'foo%'").append(ln());
sb.append(" /*LAST*/)/*END*/").append(ln());
SqlAnalyzer analyzer = new SqlAnalyzer(sb.toString(), false);
// ## Act ##
try {
analyzer.analyze();
// ## Assert ##
fail();
} catch (EndCommentNotFoundException e) {
// OK
log(e.getMessage());
}
}
use of org.dbflute.twowaysql.exception.EndCommentNotFoundException in project dbflute-core by dbflute.
the class IfNodeTest method test_parse_IF_endNotFound.
public void test_parse_IF_endNotFound() {
// ## Arrange ##
String sql = "where";
sql = sql + " /*IF pmb.memberId != null*/";
sql = sql + " select foo";
SqlAnalyzer analyzer = new SqlAnalyzer(sql, false);
// ## Act ##
try {
analyzer.analyze();
// ## Assert ##
fail();
} catch (EndCommentNotFoundException e) {
// OK
log(e.getMessage());
}
}
use of org.dbflute.twowaysql.exception.EndCommentNotFoundException in project dbflute-core by dbflute.
the class SqlAnalyzer method throwEndCommentNotFoundException.
protected void throwEndCommentNotFoundException() {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("The end comment was not found!");
br.addItem("Advice");
br.addElement("Please confirm the parameter comment logic.");
br.addElement("It may exist the parameter comment that DOESN'T have an end comment.");
br.addElement("For example:");
br.addElement(" (x): /*IF pmb.xxxId != null*/XXX_ID = /*pmb.xxxId*/3");
br.addElement(" (o): /*IF pmb.xxxId != null*/XXX_ID = /*pmb.xxxId*/3/*END*/");
br.addItem("Specified SQL");
br.addElement(_specifiedSql);
final String msg = br.buildExceptionMessage();
throw new EndCommentNotFoundException(msg);
}
use of org.dbflute.twowaysql.exception.EndCommentNotFoundException in project dbflute-core by dbflute.
the class ForNodeTest method test_accept_FIRST_endNotFound.
public void test_accept_FIRST_endNotFound() throws Exception {
// ## Arrange ##
MockPmb pmb = new MockPmb();
pmb.setMemberNameList(DfCollectionUtil.newArrayList("foo", "bar", "baz"));
pmb.setMemberNameListInternalLikeSearchOption(new LikeSearchOption().likeContain());
pmb.setMemberAccountList(DfCollectionUtil.newArrayList("ab%c", "%def"));
StringBuilder sb = new StringBuilder();
sb.append("select * from MEMBER").append(ln());
sb.append(" /*FOR pmb.memberNameList*//*FIRST*/and (").append(ln());
sb.append(" /*NEXT 'or '*/MEMBER_NAME like /*#current*/'foo%'").append(ln());
sb.append(" /*LAST*/)/*END*//*END*/").append(ln());
SqlAnalyzer analyzer = new SqlAnalyzer(sb.toString(), false);
// ## Act ##
try {
analyzer.analyze();
// ## Assert ##
fail();
} catch (EndCommentNotFoundException e) {
// OK
log(e.getMessage());
}
}
use of org.dbflute.twowaysql.exception.EndCommentNotFoundException in project dbflute-core by dbflute.
the class OutsideSqlCheckerTest method test_check_parameterComment.
public void test_check_parameterComment() {
// ## Arrange ##
DfOutsideSqlChecker ker = new DfOutsideSqlChecker();
String fn = "test.sql";
// ## Act ##
try {
ker.check(fn, "-- #df:entity#\n-- !df:pmb!\nfoo /*IF pmb.memberId != null*/bar");
// ## Assert ##
fail();
} catch (EndCommentNotFoundException e) {
// OK
log(e.getMessage());
}
// ## Act ##
try {
ker.check(fn, "-- #df:entity#\n-- !df:pmb!\nfoo /*IF */bar/*END*/");
// ## Assert ##
fail();
} catch (IfCommentConditionEmptyException e) {
// OK
log(e.getMessage());
}
}
Aggregations