use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class DefaultFileSystemTest method inputFile_supports_non_indexed_predicates.
@Test
public void inputFile_supports_non_indexed_predicates() {
fs.add(new TestInputFileBuilder("foo", "src/Bar.java").setLanguage("java").build());
// it would fail if more than one java file
assertThat(fs.inputFile(fs.predicates().hasLanguage("java"))).isNotNull();
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class DefaultCpdTokensTest method dont_save_for_test_files.
@Test
public void dont_save_for_test_files() {
DefaultInputFile testInputFile = new TestInputFileBuilder("foo", "src/Foo.java").setLines(2).setOriginalLineStartOffsets(new int[] { 0, 50 }).setOriginalLineEndOffsets(new int[] { 49, 100 }).setLastValidOffset(101).setType(InputFile.Type.TEST).build();
DefaultCpdTokens tokens = new DefaultCpdTokens(sensorStorage).onFile(testInputFile).addToken(testInputFile.newRange(1, 2, 1, 5), "foo");
tokens.save();
verifyZeroInteractions(sensorStorage);
assertThat(tokens.getTokenLines()).isEmpty();
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class SensorContextTesterTest method duplicateCpdTokens.
@Test(expected = UnsupportedOperationException.class)
public void duplicateCpdTokens() {
DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.java").initMetadata("public class Foo {\n\n}").build();
tester.newCpdTokens().onFile(inputFile).addToken(inputFile.newRange(0, 6), "public").save();
tester.newCpdTokens().onFile(inputFile).addToken(inputFile.newRange(0, 6), "public").save();
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class SensorContextTesterTest method duplicateHighlighting.
@Test(expected = UnsupportedOperationException.class)
public void duplicateHighlighting() {
tester.newHighlighting().onFile(new TestInputFileBuilder("foo", "src/Foo.java").initMetadata("annot dsf fds foo bar").build()).highlight(1, 0, 1, 5, TypeOfText.ANNOTATION).save();
tester.newHighlighting().onFile(new TestInputFileBuilder("foo", "src/Foo.java").initMetadata("annot dsf fds foo bar").build()).highlight(1, 0, 1, 5, TypeOfText.ANNOTATION).save();
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class SensorContextTesterTest method testConditions.
@Test
public void testConditions() {
assertThat(tester.conditions("foo:src/Foo.java", 1)).isNull();
assertThat(tester.coveredConditions("foo:src/Foo.java", 1)).isNull();
tester.newCoverage().onFile(new TestInputFileBuilder("foo", "src/Foo.java").initMetadata("annot dsf fds foo bar\nasd\nasdas\nasdfas").build()).conditions(1, 4, 2).save();
assertThat(tester.conditions("foo:src/Foo.java", 1)).isEqualTo(4);
assertThat(tester.coveredConditions("foo:src/Foo.java", 1)).isEqualTo(2);
}
Aggregations