Search in sources :

Example 11 with InputComponentStore

use of org.sonar.scanner.scan.filesystem.InputComponentStore in project sonarqube by SonarSource.

the class ComponentsPublisherTest method publish_project_with_links.

@Test
public void publish_project_with_links() throws Exception {
    ProjectInfo projectInfo = mock(ProjectInfo.class);
    when(projectInfo.getAnalysisDate()).thenReturn(DateUtils.parseDate("2012-12-12"));
    ProjectDefinition rootDef = ProjectDefinition.create().setKey("foo").setProperty(CoreProperties.PROJECT_VERSION_PROPERTY, "1.0").setName("Root project").setProperty(CoreProperties.LINKS_HOME_PAGE, "http://home").setProperty(CoreProperties.LINKS_CI, "http://ci").setDescription("Root description").setBaseDir(temp.newFolder()).setWorkDir(temp.newFolder());
    DefaultInputProject project = new DefaultInputProject(rootDef, 1);
    InputComponentStore store = new InputComponentStore(branchConfiguration, sonarRuntime);
    ComponentsPublisher publisher = new ComponentsPublisher(project, store);
    publisher.publish(writer);
    ScannerReportReader reader = new ScannerReportReader(outputDir);
    Component rootProtobuf = reader.readComponent(1);
    assertThat(rootProtobuf.getLinkCount()).isEqualTo(2);
    assertThat(rootProtobuf.getLink(0).getType()).isEqualTo(ComponentLinkType.HOME);
    assertThat(rootProtobuf.getLink(0).getHref()).isEqualTo("http://home");
    assertThat(rootProtobuf.getLink(1).getType()).isEqualTo(ComponentLinkType.CI);
    assertThat(rootProtobuf.getLink(1).getHref()).isEqualTo("http://ci");
}
Also used : ScannerReportReader(org.sonar.scanner.protocol.output.ScannerReportReader) DefaultInputProject(org.sonar.api.batch.fs.internal.DefaultInputProject) InputComponentStore(org.sonar.scanner.scan.filesystem.InputComponentStore) ProjectInfo(org.sonar.scanner.ProjectInfo) Component(org.sonar.scanner.protocol.output.ScannerReport.Component) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Test(org.junit.Test)

Example 12 with InputComponentStore

use of org.sonar.scanner.scan.filesystem.InputComponentStore in project sonarqube by SonarSource.

the class QProfileVerifierTest method before.

@Before
public void before() {
    store = new InputComponentStore(mock(BranchConfiguration.class), mock(SonarRuntime.class));
    profiles = mock(QualityProfiles.class);
    QProfile javaProfile = new QProfile("p1", "My Java profile", "java", null);
    when(profiles.findByLanguage("java")).thenReturn(javaProfile);
    QProfile cobolProfile = new QProfile("p2", "My Cobol profile", "cobol", null);
    when(profiles.findByLanguage("cobol")).thenReturn(cobolProfile);
}
Also used : InputComponentStore(org.sonar.scanner.scan.filesystem.InputComponentStore) Before(org.junit.Before)

Example 13 with InputComponentStore

use of org.sonar.scanner.scan.filesystem.InputComponentStore in project sonarqube by SonarSource.

the class CpdExecutorTest method setUp.

@Before
public void setUp() throws IOException {
    File outputDir = temp.newFolder();
    baseDir = temp.newFolder();
    when(publisher.getWriter()).thenReturn(new ScannerReportWriter(outputDir));
    DefaultInputProject project = TestInputFileBuilder.newDefaultInputProject("foo", baseDir);
    componentStore = new InputComponentStore(mock(BranchConfiguration.class), sonarRuntime);
    executor = new CpdExecutor(settings, index, publisher, componentStore, executorService);
    reader = new ScannerReportReader(outputDir);
    batchComponent1 = createComponent("src/Foo.php", 5);
    batchComponent2 = createComponent("src/Foo2.php", 5);
    batchComponent3 = createComponent("src/Foo3.php", 5);
}
Also used : ScannerReportReader(org.sonar.scanner.protocol.output.ScannerReportReader) DefaultInputProject(org.sonar.api.batch.fs.internal.DefaultInputProject) InputComponentStore(org.sonar.scanner.scan.filesystem.InputComponentStore) ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) Before(org.junit.Before)

Aggregations

InputComponentStore (org.sonar.scanner.scan.filesystem.InputComponentStore)13 Before (org.junit.Before)8 DefaultInputProject (org.sonar.api.batch.fs.internal.DefaultInputProject)6 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)6 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)5 PathResolver (org.sonar.api.scan.filesystem.PathResolver)5 Test (org.junit.Test)4 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)4 ProjectInfo (org.sonar.scanner.ProjectInfo)4 ScannerReportReader (org.sonar.scanner.protocol.output.ScannerReportReader)4 File (java.io.File)3 Component (org.sonar.scanner.protocol.output.ScannerReport.Component)3 ScannerReportWriter (org.sonar.scanner.protocol.output.ScannerReportWriter)3 Path (java.nio.file.Path)2 Matchers.anyString (org.mockito.Matchers.anyString)2 SonarRuntime (org.sonar.api.SonarRuntime)2 BranchConfiguration (org.sonar.scanner.scan.branch.BranchConfiguration)2 MeasureCache (org.sonar.scanner.scan.measure.MeasureCache)2 AnalysisMode (org.sonar.api.batch.AnalysisMode)1 InputFile (org.sonar.api.batch.fs.InputFile)1