Skip to content

Commit af96a79

Browse files
committed
- F InlineOptions.semiAutomatic()
1 parent 31b23fd commit af96a79

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

approvaltests/src/main/java/org/approvaltests/inline/InlineJavaReporter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ public class InlineJavaReporter implements ApprovalFailureReporter, ApprovalRepo
1515
private final String sourceFilePath;
1616
private final StackTraceNamer stackTraceNamer;
1717
private final ApprovalFailureReporter reporter;
18-
public InlineJavaReporter(ApprovalFailureReporter reporter)
18+
private final String additionalLines;
19+
20+
public InlineJavaReporter(ApprovalFailureReporter reporter, boolean addApprovalLine)
1921
{
2022
this.reporter = reporter;
2123
this.stackTraceNamer = new StackTraceNamer();
2224
this.sourceFilePath = stackTraceNamer.getSourceFilePath();
25+
this.additionalLines = addApprovalLine ? "***** DELETE ME TO APPROVE *****" : "";
2326
}
2427
public String getSourceFilePath()
2528
{
@@ -37,7 +40,7 @@ public String createReceived(String actual)
3740
String file = sourceFilePath + stackTraceNamer.getInfo().getClassName() + ".java";
3841
String received = getReceivedFileName();
3942
String text = FileUtils.readFile(file);
40-
String fullText = createNewReceivedFileText(text, actual, this.stackTraceNamer.getInfo().getMethodName());
43+
String fullText = createNewReceivedFileText(text, actual + additionalLines, this.stackTraceNamer.getInfo().getMethodName());
4144
FileUtils.writeFile(new File(received), fullText);
4245
return received;
4346
}

approvaltests/src/main/java/org/approvaltests/inline/InlineOptions.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static InlineOptions showCode(boolean doShowCode)
1010
{
1111
if (doShowCode)
1212
{
13-
return options -> options.withReporter(new InlineJavaReporter(options.getReporter()));
13+
return options -> options.withReporter(new InlineJavaReporter(options.getReporter(), false));
1414
}
1515
else
1616
{
@@ -19,6 +19,10 @@ public static InlineOptions showCode(boolean doShowCode)
1919
}
2020
public static InlineOptions automatic()
2121
{
22-
return options -> options.withReporter(new InlineJavaReporter(new AutoApproveReporter()));
22+
return options -> options.withReporter(new InlineJavaReporter(new AutoApproveReporter(), false));
23+
}
24+
public static InlineOptions semiAutomatic()
25+
{
26+
return options -> options.withReporter(new InlineJavaReporter(new AutoApproveReporter(), true));
2327
}
2428
}

0 commit comments

Comments
 (0)