Search in sources :

Example 1 with ProjectDefinition

use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.

the class TestInputFileBuilder method newDefaultInputModule.

public static DefaultInputModule newDefaultInputModule(String moduleKey, File baseDir) {
    ProjectDefinition definition = ProjectDefinition.create().setKey(moduleKey);
    definition.setBaseDir(baseDir);
    return new DefaultInputModule(definition, TestInputFileBuilder.nextBatchId());
}
Also used : ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition)

Example 2 with ProjectDefinition

use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.

the class ProjectTest method effectiveKeyShouldEqualKeyWithBranch.

@Test
public void effectiveKeyShouldEqualKeyWithBranch() {
    ProjectDefinition definition = ProjectDefinition.create().setKey("mykey").setProperty(CoreProperties.PROJECT_BRANCH_PROPERTY, "branch");
    assertThat(new Project(definition).getEffectiveKey()).isEqualTo("mykey:branch");
    assertThat(new Project(definition).getKey()).isEqualTo("mykey");
}
Also used : ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Test(org.junit.Test)

Example 3 with ProjectDefinition

use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.

the class ProjectTest method setNameWithBranch.

@Test
public void setNameWithBranch() {
    ProjectDefinition definition = ProjectDefinition.create().setProperty(CoreProperties.PROJECT_BRANCH_PROPERTY, "branch").setKey("key").setName("name");
    Project project = new Project(definition);
    assertThat(project.getName()).isEqualTo("name branch");
    assertThat(project.getOriginalName()).isEqualTo("name branch");
}
Also used : ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Test(org.junit.Test)

Example 4 with ProjectDefinition

use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.

the class QualifiersTest method testProject.

@Test
public void testProject() {
    ProjectDefinition rootDef = ProjectDefinition.create();
    ProjectDefinition moduleDef = ProjectDefinition.create();
    rootDef.addSubProject(moduleDef);
    Resource root = new Project(rootDef);
    assertThat(Qualifiers.isView(root, true)).isFalse();
    assertThat(Qualifiers.isView(root, false)).isFalse();
    assertThat(Qualifiers.isProject(root, true)).isTrue();
    assertThat(Qualifiers.isProject(root, false)).isTrue();
}
Also used : ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Test(org.junit.Test)

Example 5 with ProjectDefinition

use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.

the class ComponentsPublisher method writeLinks.

private static void writeLinks(InputComponent c, ScannerReport.Component.Builder builder) {
    if (c instanceof InputModule) {
        DefaultInputModule inputModule = (DefaultInputModule) c;
        ProjectDefinition def = inputModule.definition();
        ComponentLink.Builder linkBuilder = ComponentLink.newBuilder();
        writeProjectLink(builder, def, linkBuilder, CoreProperties.LINKS_HOME_PAGE, ComponentLinkType.HOME);
        writeProjectLink(builder, def, linkBuilder, CoreProperties.LINKS_CI, ComponentLinkType.CI);
        writeProjectLink(builder, def, linkBuilder, CoreProperties.LINKS_ISSUE_TRACKER, ComponentLinkType.ISSUE);
        writeProjectLink(builder, def, linkBuilder, CoreProperties.LINKS_SOURCES, ComponentLinkType.SCM);
        writeProjectLink(builder, def, linkBuilder, CoreProperties.LINKS_SOURCES_DEV, ComponentLinkType.SCM_DEV);
    }
}
Also used : DefaultInputModule(org.sonar.api.batch.fs.internal.DefaultInputModule) InputModule(org.sonar.api.batch.fs.InputModule) ComponentLink(org.sonar.scanner.protocol.output.ScannerReport.ComponentLink) DefaultInputModule(org.sonar.api.batch.fs.internal.DefaultInputModule) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition)

Aggregations

ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)69 Test (org.junit.Test)43 File (java.io.File)17 DefaultInputModule (org.sonar.api.batch.fs.internal.DefaultInputModule)16 ProjectReactor (org.sonar.api.batch.bootstrap.ProjectReactor)10 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)7 DefaultInputProject (org.sonar.api.batch.fs.internal.DefaultInputProject)7 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)6 Path (java.nio.file.Path)5 MessageException (org.sonar.api.utils.MessageException)5 Component (org.sonar.scanner.protocol.output.ScannerReport.Component)5 ScannerReportReader (org.sonar.scanner.protocol.output.ScannerReportReader)5 InputComponentStore (org.sonar.scanner.scan.filesystem.InputComponentStore)5 Before (org.junit.Before)4 ProjectInfo (org.sonar.scanner.ProjectInfo)4 GlobalSettings (org.sonar.scanner.bootstrap.GlobalSettings)4 AnalysisContextReportPublisher (org.sonar.scanner.report.AnalysisContextReportPublisher)4 ProjectRepositories (org.sonar.scanner.repository.ProjectRepositories)4 ArrayList (java.util.ArrayList)3 DefaultInputDir (org.sonar.api.batch.fs.internal.DefaultInputDir)3