Search in sources :

Example 1 with IfCommentConditionEmptyException

use of org.dbflute.twowaysql.exception.IfCommentConditionEmptyException in project dbflute-core by dbflute.

the class SqlAnalyzer method throwIfCommentConditionEmptyException.

protected void throwIfCommentConditionEmptyException() {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The condition of IF comment was empty!");
    br.addItem("Advice");
    br.addElement("Please confirm the IF comment expression.");
    br.addElement("Your IF comment might not have a condition.");
    br.addElement("For example:");
    br.addElement("  (x) - /*IF */XXX_ID = /*pmb.xxxId*/3/*END*/");
    br.addElement("  (o) - /*IF pmb.xxxId != null*/XXX_ID = /*pmb.xxxId*/3/*END*/");
    br.addItem("IF Comment");
    br.addElement(_tokenizer.getToken());
    br.addItem("Specified SQL");
    br.addElement(_specifiedSql);
    final String msg = br.buildExceptionMessage();
    throw new IfCommentConditionEmptyException(msg);
}
Also used : IfCommentConditionEmptyException(org.dbflute.twowaysql.exception.IfCommentConditionEmptyException) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder)

Example 2 with IfCommentConditionEmptyException

use of org.dbflute.twowaysql.exception.IfCommentConditionEmptyException in project dbflute-core by dbflute.

the class IfNodeTest method test_parse_IF_emptyCondition.

public void test_parse_IF_emptyCondition() {
    // ## Arrange ##
    String sql = "where";
    sql = sql + " /*IF */";
    sql = sql + " select foo";
    sql = sql + " /*END*/";
    SqlAnalyzer analyzer = new SqlAnalyzer(sql, false);
    // ## Act ##
    try {
        analyzer.analyze();
        // ## Assert ##
        fail();
    } catch (IfCommentConditionEmptyException e) {
        // OK
        log(e.getMessage());
    }
}
Also used : IfCommentConditionEmptyException(org.dbflute.twowaysql.exception.IfCommentConditionEmptyException) SqlAnalyzer(org.dbflute.twowaysql.SqlAnalyzer)

Example 3 with IfCommentConditionEmptyException

use of org.dbflute.twowaysql.exception.IfCommentConditionEmptyException 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());
    }
}
Also used : IfCommentConditionEmptyException(org.dbflute.twowaysql.exception.IfCommentConditionEmptyException) DfOutsideSqlChecker(org.dbflute.logic.outsidesqltest.DfOutsideSqlChecker) EndCommentNotFoundException(org.dbflute.twowaysql.exception.EndCommentNotFoundException)

Aggregations

IfCommentConditionEmptyException (org.dbflute.twowaysql.exception.IfCommentConditionEmptyException)3 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1 DfOutsideSqlChecker (org.dbflute.logic.outsidesqltest.DfOutsideSqlChecker)1 SqlAnalyzer (org.dbflute.twowaysql.SqlAnalyzer)1 EndCommentNotFoundException (org.dbflute.twowaysql.exception.EndCommentNotFoundException)1