Java Code Examples for org.sonar.api.utils.System2

The following examples show how to use org.sonar.api.utils.System2. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: SonarTsPlugin   Source File: TsLintExecutorImplTest.java    License: MIT License 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    this.system = mock(System2.class);
    this.tempFolder = mock(TempFolder.class);

    this.tempOutputFile = mock(File.class);
    when(this.tempOutputFile.getAbsolutePath()).thenReturn("path/to/temp");
    when(this.tempFolder.newFile()).thenReturn(this.tempOutputFile);

    this.commandExecutor = mock(CommandExecutor.class);

    this.executorImpl = spy(new TsLintExecutorImpl(this.system, this.tempFolder));
    when(this.executorImpl.createExecutor()).thenReturn(this.commandExecutor);
    doReturn(mock(BufferedReader.class)).when(this.executorImpl).getBufferedReaderForFile(any(File.class));

    // Setup a default config, which each method will mutate as required
    this.config = new TsLintExecutorConfig();
    this.config.setPathToNode("node");
    this.config.setPathToTsLint("path/to/tslint");
    this.config.setConfigFile("path/to/config");
    this.config.setRulesDir("path/to/rules");
    this.config.setTimeoutMs(40000);
}
 
Example 2
Source Project: sonar-ruby-plugin   Source File: RubocopSensorTest.java    License: MIT License 5 votes vote down vote up
@Test
public void testDescribe() {
    RubocopExecutor executor = new RubocopExecutor(System2.INSTANCE, new JUnitTempFolder());

    RubocopSensor sensor = new RubocopSensor(new PathResolver(), executor, new RubocopParser());

    DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
    sensor.describe(descriptor);

    assertThat(descriptor.name()).isEqualTo("Linting sensor for Ruby files");
    assertThat(descriptor.languages()).containsExactly(Ruby.LANGUAGE_KEY);
}
 
Example 3
public ScannerPullRequestPropertySensor(System2 system2) {
    super();
    this.system2 = system2;
}
 
Example 4
public CommunityBranchConfigurationLoader(System2 system2, AnalysisWarnings analysisWarnings) {
    super();
    this.system2 = system2;
    this.analysisWarnings = analysisWarnings;
}
 
Example 5
Source Project: sonar-ruby-plugin   Source File: RubocopExecutor.java    License: MIT License 4 votes vote down vote up
public RubocopExecutor(System2 system, TempFolder tempFolder) {
    this.mustQuoteSpaceContainingPaths = system.isOsWindows();
    this.tempFolder = tempFolder;
}
 
Example 6
Source Project: SonarTsPlugin   Source File: TsLintExecutorImpl.java    License: MIT License 4 votes vote down vote up
public TsLintExecutorImpl(System2 system, TempFolder tempFolder) {
    this.mustQuoteSpaceContainingPaths = system.isOsWindows();
    this.tempFolder = tempFolder;
}