]> source.dussan.org Git - sonarqube.git/commitdiff
Replace bad imports of org.elasticsearch.common by guava
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 28 Aug 2014 13:09:22 +0000 (15:09 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 28 Aug 2014 13:09:48 +0000 (15:09 +0200)
13 files changed:
server/sonar-search/pom.xml
server/sonar-search/src/test/java/org/sonar/search/script/UpdateListScriptTest.java
server/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentAppAction.java
server/sonar-server/src/main/java/org/sonar/server/permission/PermissionFinder.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndex.java
server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java
server/sonar-server/src/test/java/org/sonar/server/activity/ActivityBackendMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/activity/ActivityServiceMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QGatesWsTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleChangeMediumTest.java
sonar-application/pom.xml
sonar-batch/src/main/java/org/sonar/batch/highlighting/SyntaxHighlightingDataBuilder.java

index 4d471e4251f91c16c2e56c1a82bcf8b12b47b9df..bcb4765c7387d4f7b3b2e72efadc5e79b2610f35 100644 (file)
     </dependency>
 
     <!-- testing -->
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
index 5b60a9d5eb7af6b1812fd539ec3c33b951b0b35f..f32f8f2e057f15216489ba06b2b974d76aa3277f 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.search.script;
 
-import org.elasticsearch.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap;
 import org.elasticsearch.script.ExecutableScript;
 import org.junit.Before;
 import org.junit.Test;
@@ -35,7 +35,6 @@ public class UpdateListScriptTest {
 
   ListUpdate.UpdateListScriptFactory factory;
 
-
   @Before
   public void setUp() throws Exception {
     factory = new ListUpdate.UpdateListScriptFactory();
@@ -100,7 +99,6 @@ public class UpdateListScriptTest {
     }
   }
 
-
   @Test
   public void update_list() throws Exception {
 
@@ -117,10 +115,10 @@ public class UpdateListScriptTest {
     params.put(ListUpdate.VALUE, mapOf("key", "1", "value", "A"));
 
     ExecutableScript script = factory.newScript(params);
-    script.setNextVar("ctx", ImmutableMap.of("_source",source));
+    script.setNextVar("ctx", ImmutableMap.of("_source", source));
     script.run();
 
-    mapFields = (Collection)source.get(listField);
+    mapFields = (Collection) source.get(listField);
     System.out.println("source = " + source);
     assertThat(mapFields).hasSize(1);
 
@@ -131,9 +129,9 @@ public class UpdateListScriptTest {
     params.put(ListUpdate.ID_VALUE, "2");
     params.put(ListUpdate.VALUE, mapOf("key", "2", "value", "B"));
     script = factory.newScript(params);
-    script.setNextVar("ctx", ImmutableMap.of("_source",source));
+    script.setNextVar("ctx", ImmutableMap.of("_source", source));
     script.run();
-    mapFields = (Collection)source.get(listField);
+    mapFields = (Collection) source.get(listField);
     assertThat(mapFields).hasSize(2);
 
     // updated first item in list
@@ -143,9 +141,9 @@ public class UpdateListScriptTest {
     params.put(ListUpdate.ID_VALUE, "1");
     params.put(ListUpdate.VALUE, mapOf("key", "1", "value", "a"));
     script = factory.newScript(params);
-    script.setNextVar("ctx", ImmutableMap.of("_source",source));
+    script.setNextVar("ctx", ImmutableMap.of("_source", source));
     script.run();
-    mapFields = (Collection)source.get(listField);
+    mapFields = (Collection) source.get(listField);
     assertThat(mapFields).hasSize(2);
 
     // updated second item in list
@@ -153,11 +151,11 @@ public class UpdateListScriptTest {
     params.put(ListUpdate.FIELD, listField);
     params.put(ListUpdate.ID_FIELD, "key");
     params.put(ListUpdate.ID_VALUE, "2");
-    params.put(ListUpdate.VALUE, mapOf("key", "2", "value","b"));
+    params.put(ListUpdate.VALUE, mapOf("key", "2", "value", "b"));
     script = factory.newScript(params);
-    script.setNextVar("ctx", ImmutableMap.of("_source",source));
+    script.setNextVar("ctx", ImmutableMap.of("_source", source));
     script.run();
-    mapFields = (Collection)source.get(listField);
+    mapFields = (Collection) source.get(listField);
     assertThat(mapFields).hasSize(2);
 
     // delete first item
@@ -167,9 +165,9 @@ public class UpdateListScriptTest {
     params.put(ListUpdate.ID_VALUE, "1");
     params.put(ListUpdate.VALUE, null);
     script = factory.newScript(params);
-    script.setNextVar("ctx", ImmutableMap.of("_source",source));
+    script.setNextVar("ctx", ImmutableMap.of("_source", source));
     script.run();
-    mapFields = (Collection)source.get(listField);
+    mapFields = (Collection) source.get(listField);
     assertThat(mapFields).hasSize(1);
   }
 
@@ -179,4 +177,4 @@ public class UpdateListScriptTest {
     map.put(k1, v1);
     return map;
   }
-}
\ No newline at end of file
+}
index 6f10598e69ccec166f72eb60c4c619cfcd789d7b..4cd7bfe2dafcb590843af5c0441bb6aeeb82f069 100644 (file)
@@ -24,7 +24,7 @@ import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Multiset;
 import com.google.common.io.Resources;
-import org.elasticsearch.common.inject.internal.Strings;
+import org.apache.commons.lang.StringUtils;
 import org.sonar.api.component.Component;
 import org.sonar.api.i18n.I18n;
 import org.sonar.api.measures.CoreMetrics;
@@ -227,7 +227,7 @@ public class ComponentAppAction implements RequestHandler {
 
     json.prop("fIssues", i18n.formatInteger(UserSession.get().locale(), severitiesAggregation.size()));
     for (String severity : severitiesAggregation.elementSet()) {
-      json.prop("f" + Strings.capitalize(severity.toLowerCase()) + "Issues", i18n.formatInteger(UserSession.get().locale(), severitiesAggregation.count(severity)));
+      json.prop("f" + StringUtils.capitalize(severity.toLowerCase()) + "Issues", i18n.formatInteger(UserSession.get().locale(), severitiesAggregation.count(severity)));
     }
     json.endObject();
   }
index b8a310f65910700281906533c759b49b3b0121ff..765e49e91d52c1648d5fb01c4a7574e8488e8168 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.server.permission;
 
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
 import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.common.base.Predicate;
-import org.elasticsearch.common.collect.Iterables;
 import org.sonar.api.ServerComponent;
 import org.sonar.api.security.DefaultGroups;
 import org.sonar.api.utils.Paging;
index b61a4d9224c75a9117ea877c8fc63ab8c2c61404..088bd5af9f7a1e6055e09aca6dd2aa36bcd0e1a4 100644 (file)
@@ -21,7 +21,7 @@
 package org.sonar.server.qualityprofile;
 
 import com.google.common.collect.Lists;
-import org.elasticsearch.common.collect.Maps;
+import com.google.common.collect.Maps;
 import org.sonar.api.ServerComponent;
 import org.sonar.api.component.Component;
 import org.sonar.api.web.UserRole;
index fd7b4034fc061c21a7912cdbb8c5980b681a6310..e96cafcecbaad146b89449ace2eb96f93dafb763 100644 (file)
  */
 package org.sonar.server.qualityprofile.index;
 
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Multimap;
 import org.elasticsearch.action.search.SearchRequestBuilder;
 import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.common.collect.ImmutableList;
 import org.elasticsearch.common.settings.ImmutableSettings;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.index.query.FilterBuilders;
index 5a85557efce4d3b800a733758fa4d653a41e4380..1e5dd3561efaf85409ad152ed2aa47278090c0f6 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.server.rule.ws;
 
-import org.elasticsearch.common.collect.Maps;
+import com.google.common.collect.Maps;
 import org.sonar.api.i18n.I18n;
 import org.sonar.api.resources.Language;
 import org.sonar.api.resources.Languages;
index eb20b732a047c5d9e63c85504ad0a3e6c18019c1..2ab0d3e88bad8cc1f59ec15c3605b378a38ed067 100644 (file)
  */
 package org.sonar.server.activity;
 
-
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
 import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.common.collect.Iterables;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -104,7 +103,6 @@ public class ActivityBackendMediumTest {
     assertThat(activity.details().get(testKey)).isEqualTo(testValue);
   }
 
-
   @Test
   public void current_time_zone() {
     service.write(dbSession, Activity.Type.QPROFILE, "now");
@@ -141,7 +139,6 @@ public class ActivityBackendMediumTest {
     }
     assertThat(count).isEqualTo(max);
 
-
     // 3 assert synchronize above IndexQueue threshold
     tester.clearIndexes();
     tester.get(Platform.class).executeStartupTasks();
@@ -183,7 +180,6 @@ public class ActivityBackendMediumTest {
     }
     assertThat(count).isEqualTo(max);
 
-
     // 3 assert synchronize above IndexQueue threshold
     tester.clearIndexes();
     tester.get(Platform.class).executeStartupTasks();
@@ -198,7 +194,6 @@ public class ActivityBackendMediumTest {
 
   }
 
-
   class TestActivityLog implements ActivityLog {
 
     private final String name;
index 0e48a154e3ff0561ce49f6a6b41044fdadb8f6b2..cdd596d5ca60ce85bfae376d095b288d65fe881e 100644 (file)
@@ -21,8 +21,8 @@ package org.sonar.server.activity;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
 import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.common.collect.Iterables;
 import org.joda.time.DateTime;
 import org.junit.After;
 import org.junit.Before;
@@ -70,7 +70,6 @@ public class ActivityServiceMediumTest {
 
   @Test
   public void find_all() throws InterruptedException {
-
     service.write(dbSession, Activity.Type.QPROFILE, testValue);
     dbSession.commit();
     assertThat(index.findAll().getTotal()).isEqualTo(1);
@@ -92,7 +91,6 @@ public class ActivityServiceMediumTest {
     assertThat(activityResult.getHits().get(0).message()).isEqualTo(testValue);
   }
 
-
   @Test
   public void search_activity_log() throws InterruptedException {
 
@@ -106,7 +104,6 @@ public class ActivityServiceMediumTest {
     assertThat(activityResult.getHits().get(0).details().get(test_key)).isEqualTo(test_value);
   }
 
-
   @Test
   public void filter_by_type() {
     service.write(dbSession, Activity.Type.NONE, getActivity());
@@ -119,11 +116,11 @@ public class ActivityServiceMediumTest {
       new QueryOptions()).getHits()).hasSize(4);
 
     assertThat(service.search(new ActivityQuery()
-        .setTypes(ImmutableSet.of(Activity.Type.SERVER)),
+      .setTypes(ImmutableSet.of(Activity.Type.SERVER)),
       new QueryOptions()).getHits()).hasSize(2);
 
     assertThat(service.search(new ActivityQuery()
-        .setTypes(ImmutableSet.of(Activity.Type.QPROFILE)),
+      .setTypes(ImmutableSet.of(Activity.Type.QPROFILE)),
       new QueryOptions()).getHits()).hasSize(1);
   }
 
@@ -145,29 +142,28 @@ public class ActivityServiceMediumTest {
     dbSession.commit();
     DateTime t2 = new DateTime().plusHours(1);
 
-
     assertThat(service.search(new ActivityQuery(),
       new QueryOptions()).getHits()).hasSize(3);
 
     assertThat(service.search(new ActivityQuery()
-        .setSince(t0.minusSeconds(5).toDate()),
+      .setSince(t0.minusSeconds(5).toDate()),
       new QueryOptions()).getHits()).hasSize(3);
 
     assertThat(service.search(new ActivityQuery()
-        .setSince(t1.minusSeconds(5).toDate()),
+      .setSince(t1.minusSeconds(5).toDate()),
       new QueryOptions()).getHits()).hasSize(1);
 
     assertThat(service.search(new ActivityQuery()
-        .setSince(t2.minusSeconds(5).toDate()),
+      .setSince(t2.minusSeconds(5).toDate()),
       new QueryOptions()).getHits()).hasSize(0);
 
     assertThat(service.search(new ActivityQuery()
-        .setTo(t1.minusSeconds(5).toDate()),
+      .setTo(t1.minusSeconds(5).toDate()),
       new QueryOptions()).getHits()).hasSize(2);
 
     assertThat(service.search(new ActivityQuery()
-        .setSince(t1.minusSeconds(5).toDate())
-        .setTo(t2.plusSeconds(5).toDate()),
+      .setSince(t1.minusSeconds(5).toDate())
+      .setTo(t2.plusSeconds(5).toDate()),
       new QueryOptions()).getHits()).hasSize(1);
   }
 
@@ -203,7 +199,6 @@ public class ActivityServiceMediumTest {
     assertThat(count).isEqualTo(max);
   }
 
-
   final String test_key = "hello";
   final String test_value = "world";
   final String testValue = "hello world";
index ad089547b51a8c889a095c4ed48fd08d6cd0a488..f710b51a7b97bd1d7d2d903c9050f7b3dc87838b 100644 (file)
@@ -20,7 +20,7 @@
 package org.sonar.server.qualitygate.ws;
 
 import com.google.common.collect.ImmutableList;
-import org.elasticsearch.common.collect.Lists;
+import com.google.common.collect.Lists;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -218,7 +218,8 @@ public class QGatesWsTest {
     String name = "New QG";
     when(qGates.rename(id, name)).thenReturn(new QualityGateDto().setId(id).setName(name));
     tester.newPostRequest("api/qualitygates", "rename").setParam("id", id.toString()).setParam("name", name).execute()
-      .assertJson("{'id':42,'name':'New QG'}");;
+      .assertJson("{'id':42,'name':'New QG'}");
+    ;
   }
 
   @Test
@@ -259,7 +260,7 @@ public class QGatesWsTest {
       new QualityGateDto().setId(42L).setName("Golden"),
       new QualityGateDto().setId(43L).setName("Star"),
       new QualityGateDto().setId(666L).setName("Ninth")
-    ));
+      ));
     when(qGates.currentUserHasWritePermission()).thenReturn(false);
     tester.newGetRequest("api/qualitygates", "list").execute().assertJson(
       "{'qualitygates':[{'id':42,'name':'Golden'},{'id':43,'name':'Star'},{'id':666,'name':'Ninth'}]}");
@@ -272,7 +273,7 @@ public class QGatesWsTest {
       defaultQgate,
       new QualityGateDto().setId(43L).setName("Star"),
       new QualityGateDto().setId(666L).setName("Ninth")
-    ));
+      ));
     when(qGates.getDefault()).thenReturn(defaultQgate);
     tester.newGetRequest("api/qualitygates", "list").execute().assertJson(
       "{'qualitygates':[{'id':42,'name':'Golden'},{'id':43,'name':'Star'},{'id':666,'name':'Ninth'}],'default':42}");
@@ -293,13 +294,13 @@ public class QGatesWsTest {
     when(qGates.listConditions(gateId)).thenReturn(ImmutableList.of(
       new QualityGateConditionDto().setId(1L).setMetricKey("ncloc").setOperator("GT").setErrorThreshold("10000"),
       new QualityGateConditionDto().setId(2L).setMetricKey("new_coverage").setOperator("LT").setWarningThreshold("90").setPeriod(3)
-    ));
+      ));
     tester.newGetRequest("api/qualitygates", "show").setParam("id", Long.toString(gateId)).execute().assertJson(
       "{'id':12345,'name':'Golden','conditions':["
         + "{'id':1,'metric':'ncloc','op':'GT','error':'10000'},"
         + "{'id':2,'metric':'new_coverage','op':'LT','warning':'90','period':3}"
         + "]}"
-    );
+      );
   }
 
   @Test
@@ -310,13 +311,13 @@ public class QGatesWsTest {
     when(qGates.listConditions(qGateId)).thenReturn(ImmutableList.of(
       new QualityGateConditionDto().setId(1L).setMetricKey("ncloc").setOperator("GT").setErrorThreshold("10000"),
       new QualityGateConditionDto().setId(2L).setMetricKey("new_coverage").setOperator("LT").setWarningThreshold("90").setPeriod(3)
-    ));
+      ));
     tester.newGetRequest("api/qualitygates", "show").setParam("name", gateName).execute().assertJson(
       "{'id':12345,'name':'Golden','conditions':["
         + "{'id':1,'metric':'ncloc','op':'GT','error':'10000'},"
         + "{'id':2,'metric':'new_coverage','op':'LT','warning':'90','period':3}"
         + "]}"
-    );
+      );
   }
 
   @Test(expected = BadRequestException.class)
@@ -386,7 +387,7 @@ public class QGatesWsTest {
     List<ProjectQgateAssociation> projects = ImmutableList.of(
       new ProjectQgateAssociation().setId(42L).setName("Project One").setMember(false),
       new ProjectQgateAssociation().setId(24L).setName("Project Two").setMember(true)
-    );
+      );
     when(assoc.projects()).thenReturn(projects);
     when(projectFinder.find(any(ProjectQgateAssociationQuery.class))).thenReturn(assoc);
 
@@ -411,7 +412,7 @@ public class QGatesWsTest {
     when(assoc.hasMoreResults()).thenReturn(true);
     List<ProjectQgateAssociation> projects = ImmutableList.of(
       new ProjectQgateAssociation().setId(24L).setName("Project Two").setMember(true)
-    );
+      );
     when(assoc.projects()).thenReturn(projects);
     when(projectFinder.find(any(ProjectQgateAssociationQuery.class))).thenReturn(assoc);
 
index 68cf8394c241602626e1568d42520052ea7a6cf0..58625f7657f43ba7cd0eaa99cef37b38da9edfe0 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.server.qualityprofile;
 
-import org.elasticsearch.common.collect.Iterables;
+import com.google.common.collect.Iterables;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
index 242e6dd7c21315ecafb1eb369be5a7bf47058db8..a7e45403831262f6d6d3a873cd5a361e2ad35361 100644 (file)
               <rules>
                 <requireFilesSize>
                   <minsize>84000000</minsize>
-                  <maxsize>120000000</maxsize>
+                  <maxsize>880000000</maxsize>
                   <files>
                     <file>${project.build.directory}/sonarqube-${project.version}.zip</file>
                   </files>
index 80e784d42110e55111400721c3b9db497a37bdb9..121a6683bca7269d2aaa69b8daf9cccc17cfeac4 100644 (file)
  */
 package org.sonar.batch.highlighting;
 
+import com.google.common.collect.Sets;
 import org.sonar.api.batch.sensor.highlighting.TypeOfText;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Ordering;
-import org.elasticsearch.common.collect.Sets;
 
 import javax.annotation.Nullable;
 
@@ -38,7 +38,7 @@ public class SyntaxHighlightingDataBuilder {
     syntaxHighlightingRuleSet = Sets.newTreeSet(new Ordering<SyntaxHighlightingRule>() {
       @Override
       public int compare(@Nullable SyntaxHighlightingRule left,
-        @Nullable SyntaxHighlightingRule right) {
+                         @Nullable SyntaxHighlightingRule right) {
         int result = left.getStartPosition() - right.getStartPosition();
         if (result == 0) {
           result = left.getEndPosition() - right.getEndPosition();