-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathOutputWriterTest.java
More file actions
61 lines (49 loc) · 1.9 KB
/
OutputWriterTest.java
File metadata and controls
61 lines (49 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package analyzer;
import analyzer.test.FakeComment;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.nio.file.Path;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Named.named;
class OutputWriterTest {
@TempDir
private Path outputPath;
private OutputWriter outputWriter;
@BeforeEach
public void setup() {
outputWriter = new OutputWriter(outputPath);
}
private static Stream<Arguments> testCases() {
var empty = new OutputBuilder();
var onlyAnalysis = new OutputBuilder();
onlyAnalysis.addComment(new FakeComment());
var onlyTags = new OutputBuilder();
onlyTags.addTag("tag");
var analysisAndTags = new OutputBuilder();
analysisAndTags.addComment(new FakeComment());
analysisAndTags.addTag("tag");
return Stream.of(
Arguments.of(named("Empty output", empty.build())),
Arguments.of(named("Only analysis", onlyAnalysis.build())),
Arguments.of(named("Only tags", onlyTags.build())),
Arguments.of(named("Analysis and tags", analysisAndTags.build()))
);
}
@ParameterizedTest
@MethodSource("testCases")
void writesAnalysisJsonFile(Output output) throws IOException {
outputWriter.write(output);
assertThat(outputPath.resolve("analysis.json").toFile().exists()).isTrue();
}
@ParameterizedTest
@MethodSource("testCases")
void writesTagsJsonFile(Output output) throws IOException {
outputWriter.write(output);
assertThat(outputPath.resolve("tags.json").toFile().exists()).isTrue();
}
}