### Question:
RadlValidator implements Application { @Override public int run(Arguments arguments) { Map<String, Collection<Issue>> issues = new TreeMap<>(); String reportFileName = arguments.hasNext() ? arguments.next() : DEFAULT_REPORT_FILE_NAME; String issueReporterId = DEFAULT_ISSUE_REPORTER; if (reportFileName.endsWith(".radl")) { reportFileName = DEFAULT_REPORT_FILE_NAME; arguments.prev(); } else if (arguments.hasNext()) { issueReporterId = arguments.next(); if (issueReporterId.endsWith(".radl")) { issueReporterId = DEFAULT_ISSUE_REPORTER; arguments.prev(); } } File reportDir = new File(reportFileName).getParentFile(); validate(arguments, issues, reportDir); IssueReporter reporter = IssueReporterFactory.newInstance(issueReporterId); reporter.setReportFileName(reportFileName); reportIssues(issues, reporter); return numErrors(issues); }  static void main(String[] args); @Override int run(Arguments arguments); void validate(Arguments arguments, Map<String, Collection<Issue>> issues, File reportDir);  }### Answer:
@Test public void writesIssuesInProvidedLocation() { File issuesFile = someIssuesFile(); String radlFileName = RANDOM.string() + ".radl"; radlValidator.run(new Arguments(new String[] { issuesFile.getPath(), radlFileName })); assertTrue("Issues file not found", issuesFile.exists()); }
@Test public void returnsNonZeroExitCodeOnFailure() { String radlFileName = RANDOM.string() + ".radl"; int exitCode = radlValidator.run(new Arguments(new String[] { someIssuesFile().getPath(), radlFileName })); assertNotEquals("Exit code", 0, exitCode); }
@Test public void returnsZeroExitCodeOnSuccess() { int exitCode = radlValidator.run(new Arguments(new String[] { someIssuesFile().getPath() })); assertEquals("Exit code", 0, exitCode); }
@Test public void writesIssuesInProvidedFormat() { File issuesFile = new File(TestIssueReporter.FILE_NAME); String radlFileName = RANDOM.string() + ".radl"; radlValidator.run(new Arguments(new String[] { RANDOM.string(), TestIssueReporter.ID, radlFileName })); assertTrue("Configured issue reporter not used", issuesFile.exists()); issuesFile.delete(); }