use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class XooBlameCommandTest method testBlame.
@Test
public void testBlame() throws IOException {
File source = new File(baseDir, "src/foo.xoo");
FileUtils.write(source, "sample content");
File scm = new File(baseDir, "src/foo.xoo.scm");
FileUtils.write(scm, "123,julien,2014-12-12\n234,julien,2014-12-24");
DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage(Xoo.KEY).setModuleBaseDir(baseDir.toPath()).build();
fs.add(inputFile);
BlameOutput result = mock(BlameOutput.class);
when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile));
new XooBlameCommand().blame(input, result);
verify(result).blameResult(inputFile, Arrays.asList(new BlameLine().revision("123").author("julien").date(DateUtils.parseDate("2014-12-12")), new BlameLine().revision("234").author("julien").date(DateUtils.parseDate("2014-12-24"))));
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class OverallCoverageSensorTest method testLineHitNoConditions.
@Test
public void testLineHitNoConditions() throws IOException {
File coverage = new File(baseDir, "src/foo.xoo.overallcoverage");
FileUtils.write(coverage, "1:3\n\n#comment");
InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).setLines(10).build();
context.fileSystem().add(inputFile);
sensor.execute(context);
assertThat(context.lineHits("foo:src/foo.xoo", 1)).isEqualTo(3);
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class CpdTokenizerSensorTest method createSourceFile.
private void createSourceFile(String content) throws IOException {
File sourceFile = new File(baseDir, "src/foo.xoo");
FileUtils.write(sourceFile, content);
InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").initMetadata(content).setModuleBaseDir(baseDir.toPath()).build();
context.fileSystem().add(inputFile);
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class MeasureSensorTest method failIfMetricNotFound.
@Test
public void failIfMetricNotFound() throws IOException {
File measures = new File(baseDir, "src/foo.xoo.measures");
FileUtils.write(measures, "unknow:12\n\n#comment");
InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).build();
context.fileSystem().add(inputFile);
thrown.expect(IllegalStateException.class);
sensor.execute(context);
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class MeasureSensorTest method testExecution.
@Test
public void testExecution() throws IOException {
File measures = new File(baseDir, "src/foo.xoo.measures");
FileUtils.write(measures, "ncloc:12\nbranch_coverage:5.3\nsqale_index:300\nbool:true\n\n#comment");
InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).build();
context.fileSystem().add(inputFile);
Metric<Boolean> booleanMetric = new Metric.Builder("bool", "Bool", Metric.ValueType.BOOL).create();
when(metricFinder.<Integer>findByKey("ncloc")).thenReturn(CoreMetrics.NCLOC);
when(metricFinder.<Double>findByKey("branch_coverage")).thenReturn(CoreMetrics.BRANCH_COVERAGE);
when(metricFinder.<Long>findByKey("sqale_index")).thenReturn(CoreMetrics.TECHNICAL_DEBT);
when(metricFinder.<Boolean>findByKey("bool")).thenReturn(booleanMetric);
sensor.execute(context);
assertThat(context.measure("foo:src/foo.xoo", CoreMetrics.NCLOC).value()).isEqualTo(12);
assertThat(context.measure("foo:src/foo.xoo", CoreMetrics.BRANCH_COVERAGE).value()).isEqualTo(5.3);
assertThat(context.measure("foo:src/foo.xoo", CoreMetrics.TECHNICAL_DEBT).value()).isEqualTo(300L);
assertThat(context.measure("foo:src/foo.xoo", booleanMetric).value()).isTrue();
}
Aggregations