use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class ModuleIndexer method createChildren.
private void createChildren(DefaultInputModule parent) {
for (ProjectDefinition def : parent.definition().getSubProjects()) {
DefaultInputModule child = new DefaultInputModule(def, batchIdGenerator.get());
moduleHierarchy.index(child, parent);
componentTree.index(child, parent);
componentStore.put(child);
createChildren(child);
}
}
use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class DefaultIndexTest method shouldGetHierarchy.
@Test
public void shouldGetHierarchy() {
InputComponent component = new DefaultInputModule("module1");
InputFile file1 = new TestInputFileBuilder("module1", "src/org/foo/Bar.java").build();
when(componentStore.getByKey("module1")).thenReturn(component);
when(componentStore.getByKey("module1:src/org/foo/Bar.java")).thenReturn(file1);
when(componentTree.getParent(file1)).thenReturn(component);
when(componentTree.getChildren(component)).thenReturn(Collections.singleton(file1));
assertThat(index.getParent("module1:src/org/foo/Bar.java").getKey()).isEqualTo("module1");
assertThat(index.getParent("module1")).isNull();
assertThat(index.getChildren("module1")).containsOnly(File.create("src/org/foo/Bar.java"));
assertThat(index.getChildren("module1:src/org/foo/Bar.java")).isEmpty();
}
use of org.sonar.api.batch.fs.internal.DefaultInputModule 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");
}
use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class IssuableFactoryTest method project_should_be_issuable.
@Test
public void project_should_be_issuable() {
IssuableFactory factory = new IssuableFactory(mock(DefaultSensorContext.class));
Issuable issuable = factory.loadPerspective(Issuable.class, new DefaultInputModule("foo"));
assertThat(issuable).isNotNull();
assertThat(issuable.issues()).isEmpty();
}
use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class DefaultSensorStorageTest method shouldSaveProjectMeasureToSensorContext.
@Test
public void shouldSaveProjectMeasureToSensorContext() {
String projectKey = "myProject";
DefaultInputModule module = new DefaultInputModule(projectKey);
ArgumentCaptor<DefaultMeasure> argumentCaptor = ArgumentCaptor.forClass(DefaultMeasure.class);
when(measureCache.put(eq(module.key()), eq(CoreMetrics.NCLOC_KEY), argumentCaptor.capture())).thenReturn(null);
underTest.store(new DefaultMeasure().on(module).forMetric(CoreMetrics.NCLOC).withValue(10));
DefaultMeasure m = argumentCaptor.getValue();
assertThat(m.value()).isEqualTo(10);
assertThat(m.metric()).isEqualTo(CoreMetrics.NCLOC);
}
Aggregations