Преглед на файлове

Replace bad imports of org.elasticsearch.common by guava

tags/4.5-RC1
Simon Brandhof преди 9 години
родител
ревизия
53ff0ea1de

+ 5
- 0
server/sonar-search/pom.xml Целия файл

@@ -43,6 +43,11 @@
</dependency>

<!-- testing -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

+ 13
- 15
server/sonar-search/src/test/java/org/sonar/search/script/UpdateListScriptTest.java Целия файл

@@ -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;
}
}
}

+ 2
- 2
server/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentAppAction.java Целия файл

@@ -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();
}

+ 2
- 2
server/sonar-server/src/main/java/org/sonar/server/permission/PermissionFinder.java Целия файл

@@ -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;

+ 1
- 1
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java Целия файл

@@ -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;

+ 1
- 1
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndex.java Целия файл

@@ -19,10 +19,10 @@
*/
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;

+ 1
- 1
server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java Целия файл

@@ -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;

+ 1
- 6
server/sonar-server/src/test/java/org/sonar/server/activity/ActivityBackendMediumTest.java Целия файл

@@ -19,10 +19,9 @@
*/
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;

+ 9
- 14
server/sonar-server/src/test/java/org/sonar/server/activity/ActivityServiceMediumTest.java Целия файл

@@ -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";

+ 11
- 10
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QGatesWsTest.java Целия файл

@@ -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);


+ 1
- 1
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleChangeMediumTest.java Целия файл

@@ -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;

+ 1
- 1
sonar-application/pom.xml Целия файл

@@ -261,7 +261,7 @@
<rules>
<requireFilesSize>
<minsize>84000000</minsize>
<maxsize>120000000</maxsize>
<maxsize>880000000</maxsize>
<files>
<file>${project.build.directory}/sonarqube-${project.version}.zip</file>
</files>

+ 2
- 2
sonar-batch/src/main/java/org/sonar/batch/highlighting/SyntaxHighlightingDataBuilder.java Целия файл

@@ -19,11 +19,11 @@
*/
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();

Loading…
Отказ
Запис