Main { int run() { try { StandaloneSonarLint sonarLint = sonarLintFactory.createSonarLint(); Map<String, String> props = Util.toMap(opts.properties()); runOnce(sonarLint, props, projectHome); } catch (Exception e) { LOGGER.error("Error executing Analysis", e); return ERROR; } return SUCCESS; } Main(Options opts, SonarLintFactory sonarLintFactory, InputFileFinder fileFinder, Path projectHome); static void main(String[] args);  }
@Test public void errorStart() throws IOException { Exception e = createException("invalid operation", "analysis failed"); doThrow(e).when(sonarLint).runAnalysis(anyMapOf(String.class, String.class), any(InputFileFinder.class), any(Path.class)); assertThat(main.run()).isEqualTo(Main.ERROR); assertThat(getLogs(err)).contains("invalid operation"); }
@Test public void errorStop() { Exception e = createException("invalid operation", "analysis failed"); doThrow(e).when(sonarLint).stop(); assertThat(main.run()).isEqualTo(Main.ERROR); assertThat(getLogs(err)).contains("invalid operation"); }
@Test public void errorAnalysis() throws IOException { Exception e = createException("invalid operation", "analysis failed"); doThrow(e).when(sonarLint).runAnalysis(anyMapOf(String.class, String.class), eq(fileFinder), any(Path.class)); assertThat(main.run()).isEqualTo(Main.ERROR); assertThat(getLogs(err)).contains("invalid operation"); }
@Test public void showStack() throws IOException { Exception e = createException("invalid operation", "analysis failed"); doThrow(e).when(sonarLint).runAnalysis(anyMapOf(String.class, String.class), any(InputFileFinder.class), any(Path.class)); assertThat(main.run()).isEqualTo(Main.ERROR); assertThat(getLogs(err)).contains("invalid operation"); assertThat(getLogs(err)).contains("analysis failed"); }