[#5681] Add MockFileDatabase.nullLiteral() allowing to override the null literal in DSLContext.fetchFromTXT()
This commit is contained in:
parent
180ca47ecf
commit
43cdb9b51a
@ -127,6 +127,7 @@ public class MockFileDatabase implements MockDataProvider {
|
||||
private final Map<String, List<MockResult>> matchExactly;
|
||||
private final Map<Pattern, List<MockResult>> matchPattern;
|
||||
private final DSLContext create;
|
||||
private String nullLiteral;
|
||||
|
||||
public MockFileDatabase(File file) throws IOException {
|
||||
this(file, "UTF-8");
|
||||
@ -152,6 +153,18 @@ public class MockFileDatabase implements MockDataProvider {
|
||||
this(new StringReader(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the <code>null</code> literal, i.e. the string that should be
|
||||
* parsed as a <code>null</code> reference, rather than as the string
|
||||
* itself.
|
||||
*
|
||||
* @see DSLContext#fetchFromTXT(String, String)
|
||||
*/
|
||||
public MockFileDatabase nullLiteral(String literal) {
|
||||
this.nullLiteral = literal;
|
||||
return this;
|
||||
}
|
||||
|
||||
private MockFileDatabase(LineNumberReader reader) throws IOException {
|
||||
this.in = reader;
|
||||
this.matchExactly = new LinkedHashMap<String, List<MockResult>>();
|
||||
@ -278,7 +291,11 @@ public class MockFileDatabase implements MockDataProvider {
|
||||
rows = Integer.parseInt(rowString.substring(7).trim());
|
||||
}
|
||||
|
||||
return new MockResult(rows, create.fetchFromTXT(currentResult.toString()));
|
||||
return new MockResult(rows,
|
||||
nullLiteral == null
|
||||
? create.fetchFromTXT(currentResult.toString())
|
||||
: create.fetchFromTXT(currentResult.toString(), nullLiteral)
|
||||
);
|
||||
}
|
||||
|
||||
private String readLine() throws IOException {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user