Skip to content

Commit

Permalink
SqlRecorder: added dumpQueryBuffer, better line breaks for multi-SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Jul 15, 2022
1 parent 5b969a2 commit 886364c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ boolean record = !queryRecorder.isRecording();
} finally {
if (record) {
queryRecorder.stopRecording();
display(queryRecorder.getQueryBuffer().toString());
display(queryRecorder.dumpQueryBuffer());
}
}
}
Expand Down Expand Up @@ -524,7 +524,7 @@ boolean record = !queryRecorder.isRecording();
} finally {
if (record) {
queryRecorder.stopRecording();
display(queryRecorder.getQueryBuffer().toString());
display(queryRecorder.dumpQueryBuffer());
}
}
}
Expand Down Expand Up @@ -679,7 +679,7 @@ protected void withQueryRecorded(CheckedRunnable block) {
throw new TestException(e);
} finally {
queryRecorder.stopRecording();
display(queryRecorder.getQueryBuffer().toString());
display(queryRecorder.dumpQueryBuffer());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ public synchronized Queue<QueryEntry> getQueryBuffer() {
return new ArrayDeque<>(queryBuffer);
}

public synchronized String dumpQueryBuffer() {
StringBuilder sb = new StringBuilder("QUERIES:\n");
queryBuffer.forEach(q -> sb.append(q).append('\n'));
return sb.toString();
}

public synchronized void clearBuffer() {
queryBuffer.clear();
}
Expand Down

0 comments on commit 886364c

Please sign in to comment.