diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2017-01-11 17:49:34 +0100 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2017-01-27 16:26:30 +0100 |
commit | 7b3024ee784a83f274a8bcc76475cf2a91219283 (patch) | |
tree | cf3256f9164e5df584b41b244396c3d2f617cf7e /plugins/sonar-xoo-plugin | |
parent | 6840dc54995084e8410b5b6903353a94034cad34 (diff) | |
download | sonarqube-7b3024ee784a83f274a8bcc76475cf2a91219283.tar.gz sonarqube-7b3024ee784a83f274a8bcc76475cf2a91219283.zip |
SONAR-8622 Lazily generate metadata for input files
Diffstat (limited to 'plugins/sonar-xoo-plugin')
11 files changed, 72 insertions, 37 deletions
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/ItCoverageSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/ItCoverageSensorTest.java index 0b8c81f6c81..a5e7ccb92fc 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/ItCoverageSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/ItCoverageSensorTest.java @@ -27,7 +27,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; -import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.internal.SensorContextTester; @@ -60,7 +61,7 @@ public class ItCoverageSensorTest { @Test public void testNoExecutionIfNoCoverageFile() { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").build(); context.fileSystem().add(inputFile); sensor.execute(context); } @@ -69,7 +70,7 @@ public class ItCoverageSensorTest { public void testLineHitNoConditions() throws IOException { File coverage = new File(baseDir, "src/foo.xoo.itcoverage"); FileUtils.write(coverage, "1:3\n\n#comment"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo").setLines(10); + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setModuleBaseDir(baseDir.toPath()).setLanguage("xoo").setLines(10).build(); context.fileSystem().add(inputFile); sensor.execute(context); @@ -81,7 +82,7 @@ public class ItCoverageSensorTest { public void testLineHitAndConditions() throws IOException { File coverage = new File(baseDir, "src/foo.xoo.itcoverage"); FileUtils.write(coverage, "1:3:4:2"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo").setLines(10); + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setModuleBaseDir(baseDir.toPath()).setLanguage("xoo").setLines(10).build(); context.fileSystem().add(inputFile); sensor.execute(context); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/OverallCoverageSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/OverallCoverageSensorTest.java index 825760416e3..622553d96e2 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/OverallCoverageSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/OverallCoverageSensorTest.java @@ -27,7 +27,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; -import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.internal.SensorContextTester; @@ -60,7 +61,7 @@ public class OverallCoverageSensorTest { @Test public void testNoExecutionIfNoCoverageFile() { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).build(); context.fileSystem().add(inputFile); sensor.execute(context); } @@ -69,7 +70,7 @@ public class OverallCoverageSensorTest { public void testLineHitNoConditions() throws IOException { File coverage = new File(baseDir, "src/foo.xoo.overallcoverage"); FileUtils.write(coverage, "1:3\n\n#comment"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo").setLines(10); + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).setLines(10).build(); context.fileSystem().add(inputFile); sensor.execute(context); @@ -81,7 +82,7 @@ public class OverallCoverageSensorTest { public void testLineHitAndConditions() throws IOException { File coverage = new File(baseDir, "src/foo.xoo.overallcoverage"); FileUtils.write(coverage, "1:3:4:2"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo").setLines(10); + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).setLines(10).build(); context.fileSystem().add(inputFile); sensor.execute(context); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/UtCoverageSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/UtCoverageSensorTest.java index 129e430f0c6..744fbb76151 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/UtCoverageSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/coverage/UtCoverageSensorTest.java @@ -27,7 +27,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; -import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.internal.SensorContextTester; @@ -60,7 +61,7 @@ public class UtCoverageSensorTest { @Test public void testNoExecutionIfNoCoverageFile() { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).build(); context.fileSystem().add(inputFile); sensor.execute(context); } @@ -69,7 +70,7 @@ public class UtCoverageSensorTest { public void testLineHitNoConditions() throws IOException { File coverage = new File(baseDir, "src/foo.xoo.coverage"); FileUtils.write(coverage, "1:3\n\n#comment"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo").setLines(10); + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).setLines(10).build(); context.fileSystem().add(inputFile); sensor.execute(context); @@ -81,7 +82,7 @@ public class UtCoverageSensorTest { public void testLineHitAndConditions() throws IOException { File coverage = new File(baseDir, "src/foo.xoo.coverage"); FileUtils.write(coverage, "1:3:4:2"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo").setLines(10); + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).setLines(10).build(); context.fileSystem().add(inputFile); sensor.execute(context); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CpdTokenizerSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CpdTokenizerSensorTest.java index ff329593106..b258916d8fa 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CpdTokenizerSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CpdTokenizerSensorTest.java @@ -27,7 +27,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; -import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.internal.SensorContextTester; @@ -76,9 +77,11 @@ public class CpdTokenizerSensorTest { private void createSourceFile(String content) throws IOException { File sourceFile = new File(baseDir, "src/foo.xoo"); FileUtils.write(sourceFile, content); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo") + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo") .setLanguage("xoo") - .initMetadata(content); + .initMetadata(content) + .setModuleBaseDir(baseDir.toPath()) + .build(); context.fileSystem().add(inputFile); } diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java index cfd8be118eb..9a5649ef688 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java @@ -46,7 +46,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; -import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.measure.MetricFinder; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.internal.SensorContextTester; @@ -86,7 +87,7 @@ public class MeasureSensorTest { @Test public void testNoExecutionIfNoMeasureFile() { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").build(); context.fileSystem().add(inputFile); sensor.execute(context); } @@ -95,7 +96,7 @@ public class MeasureSensorTest { 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"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); + 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) @@ -118,7 +119,7 @@ public class MeasureSensorTest { public void failIfMetricNotFound() throws IOException { File measures = new File(baseDir, "src/foo.xoo.measures"); FileUtils.write(measures, "unknow:12\n\n#comment"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).build(); context.fileSystem().add(inputFile); thrown.expect(IllegalStateException.class); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SymbolReferencesSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SymbolReferencesSensorTest.java index f988760c5db..fc1040e3145 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SymbolReferencesSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SymbolReferencesSensorTest.java @@ -24,8 +24,9 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.internal.DefaultFileSystem; -import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.component.ResourcePerspectives; @@ -66,7 +67,7 @@ public class SymbolReferencesSensorTest { @Test public void testNoExecutionIfNoSymbolFile() { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).build(); fileSystem.add(inputFile); sensor.execute(context); } @@ -75,7 +76,7 @@ public class SymbolReferencesSensorTest { public void testExecution() throws IOException { File symbol = new File(baseDir, "src/foo.xoo.symbol"); FileUtils.write(symbol, "1:4,7\n12:15,23:33\n\n#comment"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); + InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).build(); fileSystem.add(inputFile); Symbolizable symbolizable = mock(Symbolizable.class); when(perspectives.as(Symbolizable.class, inputFile)).thenReturn(symbolizable); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java index f46573a9534..0164f1a04f4 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java @@ -27,6 +27,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.internal.SensorContextTester; import org.sonar.api.component.ResourcePerspectives; @@ -62,7 +63,10 @@ public class SyntaxHighlightingSensorTest { @Test public void testNoExecutionIfNoSyntaxFile() { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); + DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo") + .setLanguage("xoo") + .setModuleBaseDir(baseDir.toPath()) + .build(); context.fileSystem().add(inputFile); sensor.execute(context); } @@ -71,8 +75,11 @@ public class SyntaxHighlightingSensorTest { public void testExecution() throws IOException { File symbol = new File(baseDir, "src/foo.xoo.highlighting"); FileUtils.write(symbol, "1:4:k\n12:15:cppd\n\n#comment"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo") - .initMetadata(" xoo\nazertyazer\nfoo"); + DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo") + .setLanguage("xoo") + .setModuleBaseDir(baseDir.toPath()) + .initMetadata(" xoo\nazertyazer\nfoo") + .build(); context.fileSystem().add(inputFile); Highlightable highlightable = mock(Highlightable.class); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/XooTokenizerTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/XooTokenizerTest.java index a5741a255f0..fb45788e592 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/XooTokenizerTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/XooTokenizerTest.java @@ -29,6 +29,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.internal.DefaultFileSystem; import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.config.Settings; @@ -63,7 +64,10 @@ public class XooTokenizerTest { public void testExecution() throws IOException { File source = new File(baseDir, "src/foo.xoo"); FileUtils.write(source, "token1 token2 token3\ntoken4"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); + DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo") + .setLanguage("xoo") + .setModuleBaseDir(baseDir.toPath()) + .build(); fileSystem.add(inputFile); XooTokenizer tokenizer = new XooTokenizer(fileSystem); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/AnalysisErrorSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/AnalysisErrorSensorTest.java index d39b66e80f9..4810e5b5e16 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/AnalysisErrorSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/AnalysisErrorSensorTest.java @@ -33,6 +33,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.batch.fs.internal.DefaultTextPointer; +import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.sensor.error.AnalysisError; import org.sonar.api.batch.sensor.internal.SensorContextTester; @@ -65,10 +66,12 @@ public class AnalysisErrorSensorTest { createErrorFile(baseDir); int[] offsets = {10, 20, 30, 40}; - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo") + DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo") .setLanguage("xoo") .setOriginalLineOffsets(offsets) - .setLines(4); + .setModuleBaseDir(baseDir) + .setLines(4) + .build(); context = SensorContextTester.create(baseDir); context.fileSystem().add(inputFile); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java index 263eb23f625..e6fc184ce7f 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java @@ -25,6 +25,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.SonarQubeSide; import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.rule.Severity; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.internal.SensorContextTester; @@ -51,8 +52,10 @@ public class OneIssuePerLineSensorTest { @Test public void testRule() throws IOException { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY) - .initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n"); + DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.xoo") + .setLanguage(Xoo.KEY) + .initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n") + .build(); SensorContextTester context = SensorContextTester.create(temp.newFolder()); context.fileSystem().add(inputFile); @@ -66,8 +69,10 @@ public class OneIssuePerLineSensorTest { @Test public void testForceSeverity() throws IOException { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY) - .initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n"); + DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.xoo") + .setLanguage(Xoo.KEY) + .initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n") + .build(); SensorContextTester context = SensorContextTester.create(temp.newFolder()); context.fileSystem().add(inputFile); @@ -83,8 +88,10 @@ public class OneIssuePerLineSensorTest { @Test public void testProvideGap() throws IOException { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY) - .initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n"); + DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.xoo") + .setLanguage(Xoo.KEY) + .initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n") + .build(); SensorContextTester context = SensorContextTester.create(temp.newFolder()); context.fileSystem().add(inputFile); @@ -100,8 +107,10 @@ public class OneIssuePerLineSensorTest { @Test public void testProvideGap_before_5_5() throws IOException { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY) - .initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n"); + DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.xoo") + .setLanguage(Xoo.KEY) + .initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n") + .build(); SensorContextTester context = SensorContextTester.create(temp.newFolder()); context.fileSystem().add(inputFile); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java index 67b5cff3891..f7930896fb8 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java @@ -28,6 +28,7 @@ import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.internal.DefaultFileSystem; import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.scm.BlameCommand.BlameInput; import org.sonar.api.batch.scm.BlameCommand.BlameOutput; import org.sonar.api.batch.scm.BlameLine; @@ -68,7 +69,10 @@ public class XooBlameCommandTest { 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 DefaultInputFile("foo", "src/foo.xoo").setLanguage(Xoo.KEY); + DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo") + .setLanguage(Xoo.KEY) + .setModuleBaseDir(baseDir.toPath()) + .build(); fs.add(inputFile); BlameOutput result = mock(BlameOutput.class); |