Search in sources :

Example 6 with InputDir

use of org.sonar.api.batch.fs.InputDir in project sonarqube by SonarSource.

the class DefaultIndexTest method shouldTransformToResource.

@Test
public void shouldTransformToResource() {
    DefaultInputModule component = new DefaultInputModule(ProjectDefinition.create().setKey("module1").setProperty(CoreProperties.PROJECT_BRANCH_PROPERTY, "branch1"), 1);
    InputFile file1 = new TestInputFileBuilder("module1", "src/org/foo/Bar.java").build();
    InputDir dir = new DefaultInputDir("module1", "src");
    assertThat(index.toResource(component)).isInstanceOf(Project.class);
    assertThat(index.toResource(component).getKey()).isEqualTo("module1");
    assertThat(index.toResource(component).getEffectiveKey()).isEqualTo("module1:branch1");
    assertThat(index.toResource(file1)).isInstanceOf(File.class);
    assertThat(index.toResource(file1).getKey()).isEqualTo("src/org/foo/Bar.java");
    assertThat(index.toResource(file1).getPath()).isEqualTo("src/org/foo/Bar.java");
    assertThat(index.toResource(dir)).isInstanceOf(Directory.class);
    assertThat(index.toResource(dir).getKey()).isEqualTo("src");
    assertThat(index.toResource(dir).getPath()).isEqualTo("src");
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) DefaultInputModule(org.sonar.api.batch.fs.internal.DefaultInputModule) DefaultInputDir(org.sonar.api.batch.fs.internal.DefaultInputDir) InputDir(org.sonar.api.batch.fs.InputDir) DefaultInputDir(org.sonar.api.batch.fs.internal.DefaultInputDir) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Aggregations

InputDir (org.sonar.api.batch.fs.InputDir)6 Test (org.junit.Test)4 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)4 InputFile (org.sonar.api.batch.fs.InputFile)3 TaskResult (org.sonar.scanner.mediumtest.TaskResult)3 File (java.io.File)2 ScannerMediumTester (org.sonar.scanner.mediumtest.ScannerMediumTester)2 XooPlugin (org.sonar.xoo.XooPlugin)2 XooRulesDefinition (org.sonar.xoo.rule.XooRulesDefinition)2 Path (java.nio.file.Path)1 DefaultInputDir (org.sonar.api.batch.fs.internal.DefaultInputDir)1 DefaultInputModule (org.sonar.api.batch.fs.internal.DefaultInputModule)1 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)1 NewIssue (org.sonar.api.batch.sensor.issue.NewIssue)1 RuleKey (org.sonar.api.rule.RuleKey)1