aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api-impl/src/test/java
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2021-06-09 16:26:56 -0500
committersonartech <sonartech@sonarsource.com>2021-06-17 20:03:08 +0000
commit2754feca4e5fa8fdd804c827783250f48676296c (patch)
tree1ed9522bbc9eff9444fae6bf0a951d976da2b859 /sonar-plugin-api-impl/src/test/java
parent97f2c01fdd4ae863134d4aa1bf32b7dcd512b10c (diff)
downloadsonarqube-2754feca4e5fa8fdd804c827783250f48676296c.tar.gz
sonarqube-2754feca4e5fa8fdd804c827783250f48676296c.zip
SONAR-14925 Remove code deprecated before 7.0 in the Plugin API
Diffstat (limited to 'sonar-plugin-api-impl/src/test/java')
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java23
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java2
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java10
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java12
4 files changed, 24 insertions, 23 deletions
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java
index d042facca99..7a3c09c3a5b 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java
@@ -34,7 +34,6 @@ import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.api.batch.sensor.internal.SensorStorage;
import static org.sonar.api.batch.sensor.highlighting.TypeOfText.COMMENT;
-import static org.sonar.api.batch.sensor.highlighting.TypeOfText.CPP_DOC;
import static org.sonar.api.batch.sensor.highlighting.TypeOfText.KEYWORD;
public class DefaultHighlightingTest {
@@ -56,12 +55,12 @@ public class DefaultHighlightingTest {
DefaultHighlighting highlightingDataBuilder = new DefaultHighlighting(Mockito.mock(SensorStorage.class))
.onFile(INPUT_FILE)
- .highlight(0, 10, COMMENT)
+ .highlight(1, 0, 1, 10, COMMENT)
.highlight(1, 10, 1, 12, KEYWORD)
- .highlight(24, 38, KEYWORD)
- .highlight(42, 50, KEYWORD)
- .highlight(24, 65, CPP_DOC)
- .highlight(12, 20, COMMENT);
+ .highlight(1, 24, 1, 38, KEYWORD)
+ .highlight(1, 42, 2, 0, KEYWORD)
+ .highlight(1, 24, 2, 15, COMMENT)
+ .highlight(1, 12, 1, 20, COMMENT);
highlightingDataBuilder.save();
@@ -86,15 +85,15 @@ public class DefaultHighlightingTest {
rangeOf(1, 24, 2, 15),
rangeOf(1, 24, 1, 38),
rangeOf(1, 42, 2, 0));
- Assertions.assertThat(highlightingRules).extracting("textType").containsExactly(COMMENT, KEYWORD, COMMENT, CPP_DOC, KEYWORD, KEYWORD);
+ Assertions.assertThat(highlightingRules).extracting("textType").containsExactly(COMMENT, KEYWORD, COMMENT, COMMENT, KEYWORD, KEYWORD);
}
@Test
public void should_support_overlapping() {
new DefaultHighlighting(Mockito.mock(SensorStorage.class))
.onFile(INPUT_FILE)
- .highlight(0, 15, KEYWORD)
- .highlight(8, 12, CPP_DOC)
+ .highlight(1, 0, 1, 15, KEYWORD)
+ .highlight(1, 8, 1, 12, COMMENT)
.save();
}
@@ -106,7 +105,7 @@ public class DefaultHighlightingTest {
new DefaultHighlighting(Mockito.mock(SensorStorage.class))
.onFile(INPUT_FILE)
- .highlight(10, 10, KEYWORD)
+ .highlight(1, 10, 1, 10, KEYWORD)
.save();
}
@@ -118,8 +117,8 @@ public class DefaultHighlightingTest {
new DefaultHighlighting(Mockito.mock(SensorStorage.class))
.onFile(INPUT_FILE)
- .highlight(0, 10, KEYWORD)
- .highlight(8, 15, KEYWORD)
+ .highlight(1, 0, 1, 10, KEYWORD)
+ .highlight(1, 8, 1, 15, KEYWORD)
.save();
}
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java
index 719b042b277..ac6c72c24dd 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java
@@ -34,7 +34,7 @@ public class DefaultSensorDescriptorTest {
.name("Foo")
.onlyOnLanguage("java")
.onlyOnFileType(InputFile.Type.MAIN)
- .requireProperty("sonar.foo.reportPath", "sonar.foo.reportPath2")
+ .onlyWhenConfiguration(c -> c.hasKey("sonar.foo.reportPath2") && c.hasKey("sonar.foo.reportPath"))
.createIssuesForRuleRepository("squid-java");
assertThat(descriptor.name()).isEqualTo("Foo");
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java
index 62f5a7ffb67..7f9aa09466d 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java
@@ -198,8 +198,8 @@ public class SensorContextTesterTest {
tester.newHighlighting()
.onFile(new TestInputFileBuilder("foo", "src/Foo.java").initMetadata("annot dsf fds foo bar").build())
.highlight(1, 0, 1, 5, TypeOfText.ANNOTATION)
- .highlight(8, 10, TypeOfText.CONSTANT)
- .highlight(9, 10, TypeOfText.COMMENT)
+ .highlight(1, 8, 1, 10, TypeOfText.CONSTANT)
+ .highlight(1, 9, 1, 10, TypeOfText.COMMENT)
.save();
assertThat(tester.highlightingTypeAt("foo:src/Foo.java", 1, 3)).containsExactly(TypeOfText.ANNOTATION);
assertThat(tester.highlightingTypeAt("foo:src/Foo.java", 1, 9)).containsExactly(TypeOfText.CONSTANT, TypeOfText.COMMENT);
@@ -228,15 +228,15 @@ public class SensorContextTesterTest {
symbolTable
.newSymbol(1, 1, 1, 5)
- .newReference(6, 9)
.newReference(1, 10, 1, 13);
symbolTable.save();
assertThat(tester.referencesForSymbolAt("foo:src/Foo.java", 1, 0)).isNull();
assertThat(tester.referencesForSymbolAt("foo:src/Foo.java", 1, 8)).isEmpty();
- assertThat(tester.referencesForSymbolAt("foo:src/Foo.java", 1, 3)).extracting("start.line", "start.lineOffset", "end.line", "end.lineOffset").containsExactly(tuple(1, 6, 1, 9),
- tuple(1, 10, 1, 13));
+ assertThat(tester.referencesForSymbolAt("foo:src/Foo.java", 1, 3))
+ .extracting("start.line", "start.lineOffset", "end.line", "end.lineOffset")
+ .containsExactly(tuple(1, 10, 1, 13));
}
@Test(expected = UnsupportedOperationException.class)
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java
index 2aad9aeb42e..6db2e987d54 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java
@@ -27,8 +27,8 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.TextRange;
-import org.sonar.api.batch.sensor.internal.SensorStorage;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -53,11 +53,13 @@ public class DefaultSymbolTableTest {
DefaultSymbolTable symbolTableBuilder = new DefaultSymbolTable(mock(SensorStorage.class))
.onFile(INPUT_FILE);
symbolTableBuilder
- .newSymbol(0, 10)
- .newReference(12, 15)
- .newReference(2, 10, 2, 15);
+ .newSymbol(1, 0, 1, 10)
+ .newReference(2, 10, 2, 15)
+ .newReference(1, 16, 1, 20);
- symbolTableBuilder.newSymbol(1, 12, 1, 15).newReference(52, 55);
+ symbolTableBuilder
+ .newSymbol(1, 12, 1, 15)
+ .newReference(2, 1, 2, 5);
symbolTableBuilder.save();