Search in sources :

Example 1 with EndCommentNotFoundException

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());
    }
}
Also used : LikeSearchOption(org.dbflute.cbean.coption.LikeSearchOption) EndCommentNotFoundException(org.dbflute.twowaysql.exception.EndCommentNotFoundException) SqlAnalyzer(org.dbflute.twowaysql.SqlAnalyzer)

Example 2 with EndCommentNotFoundException

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());
    }
}
Also used : EndCommentNotFoundException(org.dbflute.twowaysql.exception.EndCommentNotFoundException) SqlAnalyzer(org.dbflute.twowaysql.SqlAnalyzer)

Example 3 with EndCommentNotFoundException

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);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) EndCommentNotFoundException(org.dbflute.twowaysql.exception.EndCommentNotFoundException)

Example 4 with EndCommentNotFoundException

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());
    }
}
Also used : LikeSearchOption(org.dbflute.cbean.coption.LikeSearchOption) EndCommentNotFoundException(org.dbflute.twowaysql.exception.EndCommentNotFoundException) SqlAnalyzer(org.dbflute.twowaysql.SqlAnalyzer)

Example 5 with EndCommentNotFoundException

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

Aggregations

EndCommentNotFoundException (org.dbflute.twowaysql.exception.EndCommentNotFoundException)5 SqlAnalyzer (org.dbflute.twowaysql.SqlAnalyzer)3 LikeSearchOption (org.dbflute.cbean.coption.LikeSearchOption)2 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1 DfOutsideSqlChecker (org.dbflute.logic.outsidesqltest.DfOutsideSqlChecker)1 IfCommentConditionEmptyException (org.dbflute.twowaysql.exception.IfCommentConditionEmptyException)1