use of org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerResult.ErrorContinuedSql in project dbflute-core by dbflute.
the class DfOutsideSqlTestTask method handleSqlFileFailure.
// ===================================================================================
// Exception Handling
// ==================
protected void handleSqlFileFailure(DfSqlFileFireResult fireResult, List<File> sqlFileList) {
final SQLFailureException topCause = fireResult.getBreakCause();
if (topCause != null) {
throw topCause;
}
final List<DfSqlFileRunnerResult> resultList = fireResult.getRunnerResultList();
for (DfSqlFileRunnerResult runnerResult : resultList) {
final SQLFailureException elementCause = runnerResult.getBreakCause();
if (elementCause != null) {
throw elementCause;
}
final List<ErrorContinuedSql> continuedSqlList = runnerResult.getErrorContinuedSqlList();
if (!continuedSqlList.isEmpty()) {
throwOutsideSqlTestFailureFoundException();
}
}
}
use of org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerResult.ErrorContinuedSql in project dbflute-core by dbflute.
the class DfSqlFileFireMan method buildDetailMessage.
protected String buildDetailMessage(DfSqlFileFireResult fireResult) {
final StringBuilder sb = new StringBuilder();
final List<DfSqlFileRunnerResult> runnerResultList = fireResult.getRunnerResultList();
for (DfSqlFileRunnerResult runnerResult : runnerResultList) {
final List<ErrorContinuedSql> errorContinuedSqlList = runnerResult.getErrorContinuedSqlList();
final String fileName = runnerResult.getSqlFile().getName();
final SQLFailureException breakCause = runnerResult.getBreakCause();
if (sb.length() > 0) {
sb.append(ln());
}
if (breakCause != null) {
// break by error
sb.append("x ").append(fileName);
sb.append(ln()).append(" >> (failed: Look at the exception message)");
} else {
// normal or error-continued
if (errorContinuedSqlList.isEmpty()) {
// OK or skipped
sb.append(!runnerResult.isSkippedFile() ? "o " : "v ").append(fileName);
} else {
sb.append("x ").append(fileName);
doBuildErrorContinuedMessage(sb, errorContinuedSqlList);
}
}
}
return sb.toString();
}
use of org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerResult.ErrorContinuedSql in project dbflute-core by dbflute.
the class DfSqlFileFireMan method doBuildErrorContinuedMessage.
protected void doBuildErrorContinuedMessage(StringBuilder sb, List<ErrorContinuedSql> errorContinuedSqlList) {
for (ErrorContinuedSql errorContinuedSql : errorContinuedSqlList) {
final String sql = errorContinuedSql.getSql();
sb.append(ln()).append(sql);
final SQLException sqlEx = errorContinuedSql.getSqlEx();
String message = sqlEx.getMessage();
if (sqlEx != null && message != null) {
message = message.trim();
final LineToken lineToken = new LineToken();
final List<String> tokenizedList = lineToken.tokenize(message, op -> op.delimitateBy(ln()));
int elementIndex = 0;
for (String element : tokenizedList) {
if (elementIndex == 0) {
sb.append(ln()).append(" >> ").append(element);
} else {
sb.append(ln()).append(" ").append(element);
}
++elementIndex;
}
if (isShowSQLState(sqlEx)) {
sb.append(ln());
sb.append(" (SQLState=").append(sqlEx.getSQLState());
sb.append(" ErrorCode=").append(sqlEx.getErrorCode()).append(")");
}
}
}
}
use of org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerResult.ErrorContinuedSql in project dbflute-core by dbflute.
the class DfOutsideSqlTestTask method buildFinalMessage.
protected String buildFinalMessage() {
if (_fireResult == null) {
return null;
}
final DfSqlFileFireResult fireResult = _fireResult;
int countOK = 0;
int countSkipped = 0;
int countFailure = 0;
final StringBuilder sb = new StringBuilder();
sb.append(" {Checked SQL}");
final List<DfSqlFileRunnerResult> runnerResultList = fireResult.getRunnerResultList();
for (DfSqlFileRunnerResult runnerResult : runnerResultList) {
final File sqlFile = runnerResult.getSqlFile();
final List<ErrorContinuedSql> continuedSqlList = runnerResult.getErrorContinuedSqlList();
sb.append(ln());
if (continuedSqlList.isEmpty()) {
if (_nonTargetSqlFileSet.contains(sqlFile)) {
// accurately 'v' means the SQL file may have skipped SQLs
// however SQL file for OutsideSqlTest has only one SQL normally
sb.append(" v ");
++countSkipped;
} else {
sb.append(" o ");
++countOK;
}
} else {
// you can say same as 'v'
// (anyway, look at the log for detail)
sb.append(" x ");
++countFailure;
}
sb.append(sqlFile.getName());
for (ErrorContinuedSql errorContinuedSql : continuedSqlList) {
final SQLException sqlEx = errorContinuedSql.getSqlEx();
String sqlMsg = sqlEx.getMessage();
if (sqlMsg != null) {
sqlMsg = sqlMsg.trim();
if (sqlMsg.contains(ln())) {
sqlMsg = Srl.substringFirstFront(sqlMsg, ln()).trim() + "...";
}
}
sb.append(ln()).append(" -> ").append(sqlMsg);
}
}
if (!runnerResultList.isEmpty()) {
sb.append(ln());
sb.append(ln()).append(" o: OK (").append(countOK).append(")");
if (countSkipped > 0) {
sb.append(ln()).append(" v: Skipped exists (").append(countSkipped).append(")");
}
if (countFailure > 0) {
sb.append(ln()).append(" x: Failure exists (").append(countFailure).append(")");
}
}
return sb.toString();
}
Aggregations