use of org.revapi.simple.FileArchive in project revapi by revapi.
the class TextReporterTest method testCustomTemplate.
@Test
public void testCustomTemplate() throws Exception {
Path tempFile = Files.createTempFile(new File(".").toPath(), "text-report-test", ".ftl");
try {
Files.copy(getClass().getResourceAsStream("/custom-template.ftl"), tempFile, StandardCopyOption.REPLACE_EXISTING);
TextReporter reporter = new TextReporter();
Revapi r = new Revapi(emptySet(), singleton(TextReporter.class), emptySet(), emptySet());
AnalysisContext ctx = AnalysisContext.builder(r).withConfigurationFromJSON("{\"revapi\": {\"reporter\": {\"text\": {\"template\": \"" + tempFile.toString() + "\"}}}}").withOldAPI(API.of(new FileArchive(new File("old-dummy.archive"))).build()).withNewAPI(API.of(new FileArchive(new File("new-dummy.archive"))).build()).build();
AnalysisContext reporterCtx = r.prepareAnalysis(ctx).getFirstConfigurationOrNull(TextReporter.class);
reporter.initialize(reporterCtx);
buildReports().forEach(reporter::report);
StringWriter out = new StringWriter();
PrintWriter wrt = new PrintWriter(out);
reporter.setOutput(wrt);
reporter.close();
String expected = "old1 VS new1\nold2 VS new2\n";
Assert.assertEquals(expected, out.toString());
} finally {
Files.delete(tempFile);
}
}
Aggregations