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");
}
Aggregations