diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2021-06-09 16:26:56 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-06-17 20:03:08 +0000 |
commit | 2754feca4e5fa8fdd804c827783250f48676296c (patch) | |
tree | 1ed9522bbc9eff9444fae6bf0a951d976da2b859 /sonar-plugin-api/src/test/java/org/sonar | |
parent | 97f2c01fdd4ae863134d4aa1bf32b7dcd512b10c (diff) | |
download | sonarqube-2754feca4e5fa8fdd804c827783250f48676296c.tar.gz sonarqube-2754feca4e5fa8fdd804c827783250f48676296c.zip |
SONAR-14925 Remove code deprecated before 7.0 in the Plugin API
Diffstat (limited to 'sonar-plugin-api/src/test/java/org/sonar')
15 files changed, 6 insertions, 260 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionTest.java index 61aa1a20882..c0d90ca2d34 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionTest.java @@ -59,7 +59,6 @@ public class PropertyDefinitionTest { .type(PropertyType.FLOAT) .onlyOnQualifiers(Qualifiers.MODULE) .multiValues(true) - .propertySetKey("set") .build(); assertThat(def.key()).isEqualTo("hello"); @@ -72,7 +71,6 @@ public class PropertyDefinitionTest { assertThat(def.global()).isFalse(); assertThat(def.qualifiers()).containsOnly(Qualifiers.MODULE); assertThat(def.multiValues()).isTrue(); - assertThat(def.propertySetKey()).isEqualTo("set"); assertThat(def.fields()).isEmpty(); } @@ -93,7 +91,6 @@ public class PropertyDefinitionTest { assertThat(def.global()).isFalse(); assertThat(def.qualifiers()).containsOnly(Qualifiers.PROJECT, Qualifiers.MODULE); assertThat(def.multiValues()).isTrue(); - assertThat(def.propertySetKey()).isEqualTo("set"); assertThat(def.fields()).isEmpty(); } @@ -125,7 +122,6 @@ public class PropertyDefinitionTest { assertThat(def.global()).isTrue(); assertThat(def.qualifiers()).isEmpty(); assertThat(def.multiValues()).isFalse(); - assertThat(def.propertySetKey()).isEmpty(); assertThat(def.fields()).isEmpty(); } @@ -146,7 +142,6 @@ public class PropertyDefinitionTest { assertThat(def.global()).isTrue(); assertThat(def.qualifiers()).isEmpty(); assertThat(def.multiValues()).isFalse(); - assertThat(def.propertySetKey()).isEmpty(); assertThat(def.fields()).isEmpty(); } @@ -156,7 +151,7 @@ public class PropertyDefinitionTest { .name("Hello") .fields( PropertyFieldDefinition.build("first").name("First").description("Description").options("A", "B").build(), - PropertyFieldDefinition.build("second").name("Second").type(PropertyType.INTEGER).indicativeSize(5).build()) + PropertyFieldDefinition.build("second").name("Second").type(PropertyType.INTEGER).build()) .build(); assertThat(def.type()).isEqualTo(PropertyType.PROPERTY_SET); @@ -166,12 +161,10 @@ public class PropertyDefinitionTest { assertThat(def.fields().get(0).description()).isEqualTo("Description"); assertThat(def.fields().get(0).type()).isEqualTo(PropertyType.STRING); assertThat(def.fields().get(0).options()).containsOnly("A", "B"); - assertThat(def.fields().get(0).indicativeSize()).isEqualTo(20); assertThat(def.fields().get(1).key()).isEqualTo("second"); assertThat(def.fields().get(1).name()).isEqualTo("Second"); assertThat(def.fields().get(1).type()).isEqualTo(PropertyType.INTEGER); assertThat(def.fields().get(1).options()).isEmpty(); - assertThat(def.fields().get(1).indicativeSize()).isEqualTo(5); } @Test @@ -188,12 +181,10 @@ public class PropertyDefinitionTest { assertThat(def.fields().get(0).description()).isEqualTo("Description"); assertThat(def.fields().get(0).type()).isEqualTo(PropertyType.STRING); assertThat(def.fields().get(0).options()).containsOnly("A", "B"); - assertThat(def.fields().get(0).indicativeSize()).isEqualTo(20); assertThat(def.fields().get(1).key()).isEqualTo("second"); assertThat(def.fields().get(1).name()).isEqualTo("Second"); assertThat(def.fields().get(1).type()).isEqualTo(PropertyType.INTEGER); assertThat(def.fields().get(1).options()).isEmpty(); - assertThat(def.fields().get(1).indicativeSize()).isEqualTo(5); } @Test @@ -458,7 +449,7 @@ public class PropertyDefinitionTest { @Properties(@Property(key = "hello", name = "Hello", fields = { @PropertyField(key = "first", name = "First", description = "Description", options = {"A", "B"}), - @PropertyField(key = "second", name = "Second", type = PropertyType.INTEGER, indicativeSize = 5)})) + @PropertyField(key = "second", name = "Second", type = PropertyType.INTEGER)})) static class WithPropertySet { } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java deleted file mode 100644 index 9536c53f76a..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.profiles; - -import com.google.common.collect.Lists; -import org.junit.Test; -import org.mockito.stubbing.Answer; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RuleFinder; -import org.sonar.api.rules.RulePriority; -import org.sonar.api.utils.ValidationMessages; -import org.sonar.check.BelongsToProfile; -import org.sonar.check.Priority; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class AnnotationProfileParserTest { - - @Test - public void shouldParseAnnotatedClasses() { - RuleFinder ruleFinder = mock(RuleFinder.class); - when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer( - (Answer) iom -> Rule.create((String) iom.getArguments()[0], (String) iom.getArguments()[1], (String) iom.getArguments()[1])); - - ValidationMessages messages = ValidationMessages.create(); - RulesProfile profile = new AnnotationProfileParser(ruleFinder).parse("squid", "Foo way", "java", Lists.newArrayList(FakeRule.class), messages); - - assertThat(profile.getName()).isEqualTo("Foo way"); - assertThat(profile.getLanguage()).isEqualTo("java"); - assertThat(profile.getActiveRule("squid", "fake").getSeverity()).isEqualTo(RulePriority.BLOCKER); - assertThat(messages.hasErrors()).isFalse(); - } - - @Test - public void shouldParseOnlyWantedProfile() { - RuleFinder ruleFinder = mock(RuleFinder.class); - when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer( - (Answer<Rule>) iom -> Rule.create((String) iom.getArguments()[0], (String) iom.getArguments()[1], (String) iom.getArguments()[1])); - - ValidationMessages messages = ValidationMessages.create(); - RulesProfile profile = new AnnotationProfileParser(ruleFinder).parse("squid", "Foo way", "java", Lists.newArrayList(FakeRule.class, RuleOnOtherProfile.class), messages); - - assertThat(profile.getActiveRule("squid", "fake")).isNotNull(); - assertThat(profile.getActiveRule("squid", "other")).isNull(); - } -} - -@BelongsToProfile(title = "Other profile", priority = Priority.BLOCKER) -@org.sonar.check.Rule(key = "other", priority = Priority.CRITICAL) -class RuleOnOtherProfile { -} - -@BelongsToProfile(title = "Foo way", priority = Priority.BLOCKER) -@org.sonar.check.Rule(key = "fake", priority = Priority.CRITICAL) -class FakeRule { -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalGroupsProviderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalGroupsProviderTest.java index 94ffb2ef1cc..bd1bc4c722f 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalGroupsProviderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalGroupsProviderTest.java @@ -39,7 +39,6 @@ public class ExternalGroupsProviderTest { }; String userName = "foo"; - assertThat(groupsProvider.doGetGroups(userName)).isNull(); assertThat(groupsProvider.doGetGroups(new ExternalGroupsProvider.Context(userName, mock(HttpServletRequest.class)))).isNull(); } @@ -61,22 +60,6 @@ public class ExternalGroupsProviderTest { runDoGetGroupsTests(groupsProvider, userGroupsMap); } - @Test - public void doGetGroupsDeprecatedApi() { - final Map<String, Collection<String>> userGroupsMap = getTestUserGroupMapping(); - - ExternalGroupsProvider groupsProvider = new ExternalGroupsProvider() { - @Override - public Collection<String> doGetGroups(String username) { - Preconditions.checkNotNull(username); - - return userGroupsMap.get(username); - } - }; - - runDoGetGroupsTests(groupsProvider, userGroupsMap); - } - private static void runDoGetGroupsTests(ExternalGroupsProvider groupsProvider, Map<String, Collection<String>> userGroupsMap) { for (Map.Entry<String, Collection<String>> userGroupMapEntry : userGroupsMap.entrySet()) { Collection<String> groups = groupsProvider.doGetGroups(new ExternalGroupsProvider.Context( diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalUsersProviderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalUsersProviderTest.java index 9437518f57a..90552931374 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalUsersProviderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalUsersProviderTest.java @@ -47,21 +47,4 @@ public class ExternalUsersProviderTest { assertThat(user.getName()).isEqualTo("foo"); assertThat(user.getEmail()).isEqualTo("foo@bar.com"); } - - @Test - public void doGetUserDetails_deprecated_api() { - ExternalUsersProvider provider = new ExternalUsersProvider() { - @Override - public UserDetails doGetUserDetails(String username) { - UserDetails user = new UserDetails(); - user.setName(username); - user.setEmail("foo@bar.com"); - return user; - } - }; - UserDetails user = provider.doGetUserDetails(new ExternalUsersProvider.Context("foo", mock(HttpServletRequest.class))); - - assertThat(user.getName()).isEqualTo("foo"); - assertThat(user.getEmail()).isEqualTo("foo@bar.com"); - } } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java index fe17affc6db..a965ce51e76 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java @@ -29,13 +29,12 @@ import java.net.URL; import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.Assume; import org.junit.Rule; import org.junit.Test; -import org.junit.jupiter.api.Assertions; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import org.sonar.api.impl.server.RulesDefinitionContext; import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleScope; import org.sonar.api.rule.RuleStatus; @@ -43,12 +42,9 @@ import org.sonar.api.rule.Severity; import org.sonar.api.rules.RuleType; import org.sonar.api.server.debt.DebtRemediationFunction; import org.sonar.api.utils.log.LogTester; -import org.sonar.api.impl.server.RulesDefinitionContext; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.useDefaultDateFormatsOnly; import static org.junit.Assert.fail; -import static org.junit.jupiter.api.Assertions.assertEquals; @RunWith(DataProviderRunner.class) public class RulesDefinitionTest { @@ -577,17 +573,6 @@ public class RulesDefinitionTest { } @Test - public void sqale_characteristic_is_deprecated_and_is_ignored() { - RulesDefinition.NewRepository newRepository = context.createRepository("findbugs", "java"); - newRepository.createRule("NPE").setName("NPE").setHtmlDescription("desc") - .setDebtSubCharacteristic(RulesDefinition.SubCharacteristics.API_ABUSE); - newRepository.done(); - - RulesDefinition.Rule rule = context.repository("findbugs").rule("NPE"); - assertThat(rule.debtSubCharacteristic()).isNull(); - } - - @Test public void type_is_defined() { RulesDefinition.NewRepository newRepository = context.createRepository("findbugs", "java"); newRepository.createRule("NPE").setName("NPE").setHtmlDescription("desc") diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionXmlLoaderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionXmlLoaderTest.java index c45475af3a9..47a80d25b28 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionXmlLoaderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionXmlLoaderTest.java @@ -230,25 +230,6 @@ public class RulesDefinitionXmlLoaderTest { } @Test - public void ignore_deprecated_sqale_characteristic() { - String xml = "" + - "<rules>" + - " <rule>" + - " <key>1</key>" + - " <name>One</name>" + - " <description>Desc</description>" + - " <effortToFixDescription>lines</effortToFixDescription>" + - " <debtSubCharacteristic>BUG</debtSubCharacteristic>" + - " <remediationFunction>LINEAR_OFFSET</remediationFunction>" + - " <remediationFunctionGapMultiplier>2d 3h</remediationFunctionGapMultiplier>" + - " <remediationFunctionBaseEffort>5min</remediationFunctionBaseEffort>" + - " </rule>" + - "</rules>"; - RulesDefinition.Rule rule = load(xml).rule("1"); - assertThat(rule.debtSubCharacteristic()).isNull(); - } - - @Test public void markdown_description() { String xml = "" + "<rules>" + diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultNewRuleTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultNewRuleTest.java index c482d9c6945..a8eb9d21bae 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultNewRuleTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultNewRuleTest.java @@ -67,12 +67,9 @@ public class DefaultNewRuleTest { rule.addTags("tag3"); assertThat(rule.tags()).containsExactly("tag1", "tag2", "tag3"); - rule.setEffortToFixDescription("effort"); + rule.setGapDescription("effort"); assertThat(rule.gapDescription()).isEqualTo("effort"); - rule.setGapDescription("gap"); - assertThat(rule.gapDescription()).isEqualTo("gap"); - rule.setInternalKey("internal"); assertThat(rule.internalKey()).isEqualTo("internal"); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultRuleTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultRuleTest.java index a8b6a1b5ec8..4d266504e4f 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultRuleTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultRuleTest.java @@ -44,7 +44,6 @@ public class DefaultRuleTest { RulesDefinition.NewParam param1 = rule.createParam("param1"); rule.setTags("tag1", "tag2"); rule.addTags("tag3"); - rule.setEffortToFixDescription("effort"); rule.setGapDescription("gap"); rule.setInternalKey("internal"); rule.addDeprecatedRuleKey("deprecatedrepo", "deprecatedkey"); @@ -64,7 +63,6 @@ public class DefaultRuleTest { assertThat(defaultRule.activatedByDefault()).isTrue(); assertThat(defaultRule.params()).containsOnly(new DefaultParam(new DefaultNewParam("param1"))); assertThat(defaultRule.tags()).containsOnly("tag1", "tag2", "tag3"); - assertThat(defaultRule.effortToFixDescription()).isEqualTo("gap"); assertThat(defaultRule.gapDescription()).isEqualTo("gap"); assertThat(defaultRule.internalKey()).isEqualTo("internal"); assertThat(defaultRule.deprecatedRuleKeys()).containsOnly(RuleKey.of("deprecatedrepo", "deprecatedkey")); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RequestTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RequestTest.java index 2cb3d37f714..2baebb55587 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RequestTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RequestTest.java @@ -227,8 +227,6 @@ public class RequestTest { @Test public void paramAsInt() { assertThat(underTest.setParam("a_number", "123").paramAsInt("a_number")).isEqualTo(123); - assertThat(underTest.setParam("a_number", "123").paramAsInt("a_number", 42)).isEqualTo(123); - assertThat(underTest.setParam("a_number", null).paramAsInt("a_number", 42)).isEqualTo(123); } @Test @@ -240,18 +238,8 @@ public class RequestTest { } @Test - public void fail_when_param_is_not_an_int_with_default_value() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("The 'a_number' parameter cannot be parsed as an integer value: not_an_int"); - - underTest.setParam("a_number", "not_an_int").paramAsInt("a_number", 42); - } - - @Test public void param_as_long() { assertThat(underTest.setParam("a_number", "123").paramAsLong("a_number")).isEqualTo(123L); - assertThat(underTest.setParam("a_number", "123").paramAsLong("a_number", 42L)).isEqualTo(123L); - assertThat(underTest.setParam("a_number", null).paramAsLong("a_number", 42L)).isEqualTo(123L); } @Test @@ -263,14 +251,6 @@ public class RequestTest { } @Test - public void fail_when_param_is_not_a_long_with_default_value() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("The 'a_number' parameter cannot be parsed as a long value: not_a_long"); - - underTest.setParam("a_number", "not_a_long").paramAsLong("a_number", 42L); - } - - @Test public void param_as_boolean() { assertThat(underTest.setParam("a_boolean", "true").paramAsBoolean("a_boolean")).isTrue(); assertThat(underTest.setParam("a_boolean", "yes").paramAsBoolean("a_boolean")).isTrue(); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/test/TestCaseTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/test/TestCaseTest.java deleted file mode 100644 index 5f2b44aefe3..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/test/TestCaseTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.test; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class TestCaseTest { - @Test - public void value_of_status() { - assertThat(TestCase.Status.of("OK")).isEqualTo(TestCase.Status.OK); - assertThat(TestCase.Status.of("OK")).isEqualTo(TestCase.Status.OK); - assertThat(TestCase.Status.of(null)).isNull(); - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/AnnotationUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/AnnotationUtilsTest.java index ae241088844..b0b487cf2a4 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/AnnotationUtilsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/AnnotationUtilsTest.java @@ -37,12 +37,6 @@ public class AnnotationUtilsTest { } @Test - public void getClassAnnotationWithDeprecatedMethod() { - FakeAnnotation annotation = AnnotationUtils.getClassAnnotation(new SuperClass(), FakeAnnotation.class); - assertThat(annotation.value()).isEqualTo("foo"); - } - - @Test public void searchClassAnnotationInSuperClass() { FakeAnnotation annotation = AnnotationUtils.getAnnotation(new ChildClass(), FakeAnnotation.class); assertThat(annotation.value()).isEqualTo("foo"); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/System2Test.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/System2Test.java index 395b6566c9b..6fcd1f07d24 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/System2Test.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/System2Test.java @@ -89,11 +89,6 @@ public class System2Test { } @Test - public void isJavaAtLeast17_always_returns_true() { - assertThat(System2.INSTANCE.isJavaAtLeast17()).isTrue(); - } - - @Test public void testPrintln() { // well, how to assert that ? Adding a System3 dependency to System2 ? :-) System2.INSTANCE.println("foo"); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/VersionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/VersionTest.java index 2c71bfd18e0..c7b904292e6 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/VersionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/VersionTest.java @@ -123,9 +123,6 @@ public class VersionTest { public void test_create() { assertVersion(Version.create(1, 2), 1, 2, 0, 0, ""); assertVersion(Version.create(1, 2, 3), 1, 2, 3, 0, ""); - assertVersion(Version.create(1, 2, 0, ""), 1, 2, 0, 0, ""); - assertVersion(Version.create(1, 2, 3, "build1"), 1, 2, 3, 0, "build1"); - assertThat(Version.create(1, 2, 3, "build1").toString()).isEqualTo("1.2.3-build1"); } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/ZipUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/ZipUtilsTest.java index 7e498be7e10..bcdad396650 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/ZipUtilsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/ZipUtilsTest.java @@ -92,24 +92,6 @@ public class ZipUtilsTest { } @Test - public void unzipping_file_extracts_subset_of_files() throws IOException { - File zip = FileUtils.toFile(urlToZip()); - File toDir = temp.newFolder(); - - ZipUtils.unzip(zip, toDir, (ZipUtils.ZipEntryFilter)ze -> ze.getName().equals("foo.txt")); - assertThat(toDir.listFiles()).containsOnly(new File(toDir, "foo.txt")); - } - - @Test - public void unzipping_stream_extracts_subset_of_files() throws IOException { - InputStream zip = urlToZip().openStream(); - File toDir = temp.newFolder(); - - ZipUtils.unzip(zip, toDir, (ZipUtils.ZipEntryFilter)ze -> ze.getName().equals("foo.txt")); - assertThat(toDir.listFiles()).containsOnly(new File(toDir, "foo.txt")); - } - - @Test public void fail_if_unzipping_file_outside_target_directory() throws Exception { File zip = new File(getClass().getResource("ZipUtilsTest/zip-slip.zip").toURI()); File toDir = temp.newFolder(); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/web/ServletFilterTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/web/ServletFilterTest.java index 15acc0ae17b..5fe2fdfc1b8 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/web/ServletFilterTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/web/ServletFilterTest.java @@ -208,19 +208,8 @@ public class ServletFilterTest { @Test public void getUrl_returns_single_inclusion() { - assertThat(ServletFilter.UrlPattern.create("/*").getUrl()).isEqualTo("/*"); - assertThat(ServletFilter.UrlPattern.create("/foo/bar").getUrl()).isEqualTo("/foo/bar"); - } - - @Test - public void getUrl_throws_ISE_if_many_urls() { - thrown.expect(IllegalStateException.class); - thrown.expectMessage("this method is deprecated and should not be used anymore"); - - ServletFilter.UrlPattern.builder() - .includes("/foo/*", "/foo/lo*") - .excludes("/foo/login", "/foo/logout", "/foo/list") - .build().getUrl(); + assertThat(ServletFilter.UrlPattern.create("/*").getInclusions()).containsOnly("/*"); + assertThat(ServletFilter.UrlPattern.create("/foo/bar").getInclusions()).containsOnly("/foo/bar"); } @Test |