|
4 | 4 | import org.approvaltests.core.ApprovalFailureReporter; |
5 | 5 | import org.approvaltests.core.Options; |
6 | 6 | import org.approvaltests.namer.ApprovalNamer; |
7 | | -import org.approvaltests.namer.StackTraceNamer; |
8 | 7 |
|
9 | 8 | import java.io.File; |
10 | 9 | import java.io.IOException; |
11 | 10 |
|
12 | 11 | import static org.approvaltests.writers.Writer.approved; |
13 | 12 | import static org.approvaltests.writers.Writer.received; |
14 | 13 |
|
15 | | -public class InlineComparator implements ApprovalNamer, ApprovalFailureReporter |
| 14 | +public class InlineComparator implements ApprovalNamer |
16 | 15 | { |
17 | | - private final InlineJavaReporter inlineJavaReporter; |
18 | | - private String expected; |
19 | | - private File approvedFile; |
20 | | - private File receivedFile; |
| 16 | + private ApprovalFailureReporter reporter = null; |
| 17 | + private final String expected; |
| 18 | + private File approvedFile; |
| 19 | + private File receivedFile; |
21 | 20 | public InlineComparator(String expected, ApprovalFailureReporter reporter) |
22 | 21 | { |
23 | 22 | this.expected = expected; |
24 | | - inlineJavaReporter = new InlineJavaReporter(reporter); |
| 23 | + if (reporter != null) |
| 24 | + { |
| 25 | + this.reporter = new InlineJavaReporter(reporter); |
| 26 | + } |
25 | 27 | } |
26 | 28 | @Override |
27 | 29 | public File getApprovedFile(String extensionWithDot) |
@@ -69,25 +71,18 @@ public String getApprovalName() |
69 | 71 | @Override |
70 | 72 | public String getSourceFilePath() |
71 | 73 | { |
72 | | - return inlineJavaReporter.getSourceFilePath(); |
| 74 | + return ""; |
73 | 75 | } |
74 | | - @Override |
75 | 76 | public boolean report(String received, String approved) |
76 | 77 | { |
77 | | - return inlineJavaReporter.report(received, approved); |
| 78 | + return reporter.report(received, approved); |
78 | 79 | } |
79 | | - private String createReceived(String actual) |
80 | | - { |
81 | | - return inlineJavaReporter.createReceived(actual); |
82 | | - } |
83 | | - |
84 | 80 | public Options setForOptions(Options options) |
85 | 81 | { |
86 | | - if (inlineJavaReporter.reporter != null) |
| 82 | + if (reporter != null) |
87 | 83 | { |
88 | | - options = options.withReporter(this); |
| 84 | + options = options.withReporter(reporter); |
89 | 85 | } |
90 | | - return options// |
91 | | - .forFile().withNamer(this); |
| 86 | + return options.forFile().withNamer(this); |
92 | 87 | } |
93 | 88 | } |
0 commit comments