diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2018-03-10 15:33:35 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2018-03-12 09:24:24 +0100 |
commit | 98550e39c25d24f68d454d8939e4352b820aedd2 (patch) | |
tree | f3a69f7cbd235922a41384a637e175a4ad4364ad /server/sonar-server | |
parent | b8634fb7e4ec5925713db6e183a62aedc3a7aac1 (diff) | |
download | sonarqube-98550e39c25d24f68d454d8939e4352b820aedd2.tar.gz sonarqube-98550e39c25d24f68d454d8939e4352b820aedd2.zip |
Clean-up ES module in sonar-server
Diffstat (limited to 'server/sonar-server')
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/es/EsModule.java (renamed from server/sonar-server/src/main/java/org/sonar/server/search/EsSearchModule.java) | 6 | ||||
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java | 4 | ||||
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java | 13 | ||||
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/search/FacetValue.java | 66 | ||||
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/search/package-info.java | 23 | ||||
-rw-r--r-- | server/sonar-server/src/test/java/org/sonar/server/es/EsModuleTest.java (renamed from server/sonar-server/src/test/java/org/sonar/server/search/EsSearchModuleTest.java) | 6 | ||||
-rw-r--r-- | server/sonar-server/src/test/java/org/sonar/server/search/FacetValueTest.java | 56 |
7 files changed, 7 insertions, 167 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/EsSearchModule.java b/server/sonar-server/src/main/java/org/sonar/server/es/EsModule.java index 77db6844064..bb306dc55fc 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/EsSearchModule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/EsModule.java @@ -17,14 +17,12 @@ * 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.server.search; +package org.sonar.server.es; import org.sonar.core.platform.Module; -import org.sonar.server.es.EsClientProvider; -import org.sonar.server.es.EsClientStopper; import org.sonar.server.permission.index.AuthorizationTypeSupport; -public class EsSearchModule extends Module { +public class EsModule extends Module { @Override protected void configureModule() { add(AuthorizationTypeSupport.class); diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java index f86edc0e288..5dc9e5b92f7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java @@ -43,6 +43,7 @@ import org.sonar.process.logging.LogbackHelper; import org.sonar.server.app.ProcessCommandWrapperImpl; import org.sonar.server.app.RestartFlagHolderImpl; import org.sonar.server.app.WebServerProcessLogging; +import org.sonar.server.es.EsModule; import org.sonar.server.issue.index.IssueIndex; import org.sonar.server.platform.LogServerVersion; import org.sonar.server.platform.Platform; @@ -52,7 +53,6 @@ import org.sonar.server.platform.UrlSettings; import org.sonar.server.platform.WebServerImpl; import org.sonar.server.platform.db.EmbeddedDatabaseFactory; import org.sonar.server.rule.index.RuleIndex; -import org.sonar.server.search.EsSearchModule; import org.sonar.server.setting.ThreadLocalSettings; import org.sonar.server.user.SystemPasscodeImpl; import org.sonar.server.user.ThreadLocalUserSession; @@ -112,7 +112,7 @@ public class PlatformLevel1 extends PlatformLevel { DaoModule.class, // Elasticsearch - EsSearchModule.class, + EsModule.class, // rules/qprofiles RuleIndex.class, diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java index f6fe4d1dadd..ae94ead30eb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java +++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java @@ -23,10 +23,8 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ListMultimap; import java.lang.annotation.Annotation; -import java.util.Collection; import java.util.Map; import java.util.Set; -import javax.annotation.Nullable; import org.sonar.api.ExtensionProvider; import org.sonar.api.Plugin; import org.sonar.api.SonarRuntime; @@ -37,7 +35,6 @@ import org.sonar.core.platform.ComponentContainer; import org.sonar.core.platform.PluginInfo; import org.sonar.core.platform.PluginRepository; -import static com.google.common.base.Preconditions.checkArgument; import static java.util.Objects.requireNonNull; /** @@ -50,16 +47,6 @@ public abstract class ServerExtensionInstaller { private final Set<Class<? extends Annotation>> supportedAnnotationTypes; protected ServerExtensionInstaller(SonarRuntime sonarRuntime, PluginRepository pluginRepository, - @Nullable Collection<Class<? extends Annotation>> supportedAnnotationTypes) { - checkArgument(supportedAnnotationTypes != null && !supportedAnnotationTypes.isEmpty(), - "At least one supported annotation type must be specified"); - this.sonarRuntime = sonarRuntime; - this.pluginRepository = pluginRepository; - this.supportedAnnotationTypes = ImmutableSet.copyOf(supportedAnnotationTypes); - - } - - protected ServerExtensionInstaller(SonarRuntime sonarRuntime, PluginRepository pluginRepository, Class<? extends Annotation>... supportedAnnotationTypes) { requireNonNull(supportedAnnotationTypes, "At least one supported annotation type must be specified"); this.sonarRuntime = sonarRuntime; diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/FacetValue.java b/server/sonar-server/src/main/java/org/sonar/server/search/FacetValue.java deleted file mode 100644 index 06c3b722212..00000000000 --- a/server/sonar-server/src/main/java/org/sonar/server/search/FacetValue.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.server.search; - -public class FacetValue { - - private final String key; - private final long value; - - public FacetValue(String key, long value) { - this.key = key; - this.value = value; - } - - public String getKey() { - return key; - } - - public long getValue() { - return value; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - FacetValue that = (FacetValue) o; - if (key == null) { - return that.key == null; - } else { - return key.equals(that.key); - } - } - - @Override - public int hashCode() { - return key != null ? key.hashCode() : 0; - } - - @Override - public String toString() { - return String.format("{%s=%d}", getKey(), getValue()); - } -} diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/search/package-info.java deleted file mode 100644 index 1ab46781f8e..00000000000 --- a/server/sonar-server/src/main/java/org/sonar/server/search/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.search; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/EsSearchModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/EsModuleTest.java index 2bc33e5fd5f..972f8ad3ee9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/search/EsSearchModuleTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/es/EsModuleTest.java @@ -17,18 +17,18 @@ * 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.server.search; +package org.sonar.server.es; import org.junit.Test; import org.sonar.core.platform.ComponentContainer; import static org.assertj.core.api.Assertions.assertThat; -public class EsSearchModuleTest { +public class EsModuleTest { @Test public void verify_count_of_added_components() { ComponentContainer container = new ComponentContainer(); - new EsSearchModule().configure(container); + new EsModule().configure(container); assertThat(container.size()).isEqualTo(3 + 2); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/FacetValueTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/FacetValueTest.java deleted file mode 100644 index 4b42d0d9d85..00000000000 --- a/server/sonar-server/src/test/java/org/sonar/server/search/FacetValueTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.server.search; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class FacetValueTest { - - @Test - public void should_check_for_equality_on_key() { - FacetValue facetValue = new FacetValue("polop", 42); - assertThat(facetValue.equals(facetValue)).isTrue(); - assertThat(facetValue.equals(null)).isFalse(); - assertThat(facetValue.equals(new Object())).isFalse(); - - assertThat(facetValue.equals(new FacetValue("polop", 666))).isTrue(); - assertThat(facetValue.equals(new FacetValue("palap", 42))).isFalse(); - - FacetValue withNullKey = new FacetValue(null, 42); - assertThat(facetValue.equals(withNullKey)).isFalse(); - assertThat(withNullKey.equals(withNullKey)).isTrue(); - assertThat(withNullKey.equals(facetValue)).isFalse(); - assertThat(withNullKey.equals(new FacetValue(null, 666))).isTrue(); - } - - @Test - public void should_use_key_hashcode() { - assertThat(new FacetValue(null, 42).hashCode()).isZero(); - String key = "polop"; - assertThat(new FacetValue(key, 666).hashCode()).isEqualTo(key.hashCode()); - } - - @Test - public void test_toString() { - assertThat(new FacetValue("polop", 42).toString()).isEqualTo("{polop=42}"); - } -} |