use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class InputFileBuilderTest method setUp.
@Before
public void setUp() throws IOException {
baseDir = temp.newFolder().toPath();
DefaultInputModule module = new DefaultInputModule(ProjectDefinition.create().setKey("module1").setBaseDir(baseDir.toFile()), 0);
PathResolver pathResolver = new PathResolver();
LanguageDetection langDetection = mock(LanguageDetection.class);
MetadataGenerator metadataGenerator = mock(MetadataGenerator.class);
BatchIdGenerator idGenerator = new BatchIdGenerator();
Settings settings = new MapSettings();
builder = new InputFileBuilder(module, pathResolver, langDetection, metadataGenerator, idGenerator, settings);
}
use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class SymbolizableBuilderTest method project_should_not_be_highlightable.
@Test
public void project_should_not_be_highlightable() {
SymbolizableBuilder builder = new SymbolizableBuilder(mock(DefaultSensorStorage.class), mock(AnalysisMode.class));
Perspective perspective = builder.loadPerspective(Symbolizable.class, new DefaultInputModule("struts"));
assertThat(perspective).isNull();
}
use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class MetadataPublisher method addModulesRelativePaths.
private void addModulesRelativePaths(ScannerReport.Metadata.Builder builder) {
LinkedList<DefaultInputModule> queue = new LinkedList<>();
queue.add(moduleHierarchy.root());
while (!queue.isEmpty()) {
DefaultInputModule module = queue.removeFirst();
queue.addAll(moduleHierarchy.children(module));
String relativePath = moduleHierarchy.relativePathToRoot(module);
if (relativePath != null) {
builder.putModulesProjectRelativePathByKey(module.key(), relativePath);
}
}
ScmProvider scmProvider = scmConfiguration.provider();
if (scmProvider == null) {
return;
}
Path projectBasedir = moduleHierarchy.root().getBaseDir();
try {
builder.setRelativePathFromScmRoot(toSonarQubePath(scmProvider.relativePathFromScmRoot(projectBasedir)));
} catch (UnsupportedOperationException e) {
LOG.debug(e.getMessage());
}
}
use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class ModuleIndexer method indexChildren.
private void indexChildren(DefaultInputModule parent) {
for (DefaultInputModule module : moduleHierarchy.children(parent)) {
componentStore.put(module);
indexChildren(module);
}
}
use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class SensorContextTesterTest method testMeasures.
@Test
public void testMeasures() throws IOException {
assertThat(tester.measures("foo:src/Foo.java")).isEmpty();
assertThat(tester.measure("foo:src/Foo.java", "ncloc")).isNull();
tester.<Integer>newMeasure().on(new TestInputFileBuilder("foo", "src/Foo.java").build()).forMetric(CoreMetrics.NCLOC).withValue(2).save();
assertThat(tester.measures("foo:src/Foo.java")).hasSize(1);
assertThat(tester.measure("foo:src/Foo.java", "ncloc")).isNotNull();
tester.<Integer>newMeasure().on(new TestInputFileBuilder("foo", "src/Foo.java").build()).forMetric(CoreMetrics.LINES).withValue(4).save();
assertThat(tester.measures("foo:src/Foo.java")).hasSize(2);
assertThat(tester.measure("foo:src/Foo.java", "ncloc")).isNotNull();
assertThat(tester.measure("foo:src/Foo.java", "lines")).isNotNull();
tester.<Integer>newMeasure().on(new DefaultInputModule(ProjectDefinition.create().setKey("foo").setBaseDir(temp.newFolder()).setWorkDir(temp.newFolder()))).forMetric(CoreMetrics.DIRECTORIES).withValue(4).save();
assertThat(tester.measures("foo")).hasSize(1);
assertThat(tester.measure("foo", "directories")).isNotNull();
}
Aggregations