</dependency>
<!-- testing -->
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
*/
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;
ListUpdate.UpdateListScriptFactory factory;
-
@Before
public void setUp() throws Exception {
factory = new ListUpdate.UpdateListScriptFactory();
}
}
-
@Test
public void update_list() throws Exception {
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);
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
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
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
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);
}
map.put(k1, v1);
return map;
}
-}
\ No newline at end of file
+}
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;
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();
}
*/
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;
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;
*/
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;
*/
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;
*/
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;
assertThat(activity.details().get(testKey)).isEqualTo(testValue);
}
-
@Test
public void current_time_zone() {
service.write(dbSession, Activity.Type.QPROFILE, "now");
}
assertThat(count).isEqualTo(max);
-
// 3 assert synchronize above IndexQueue threshold
tester.clearIndexes();
tester.get(Platform.class).executeStartupTasks();
}
assertThat(count).isEqualTo(max);
-
// 3 assert synchronize above IndexQueue threshold
tester.clearIndexes();
tester.get(Platform.class).executeStartupTasks();
}
-
class TestActivityLog implements ActivityLog {
private final String name;
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;
@Test
public void find_all() throws InterruptedException {
-
service.write(dbSession, Activity.Type.QPROFILE, testValue);
dbSession.commit();
assertThat(index.findAll().getTotal()).isEqualTo(1);
assertThat(activityResult.getHits().get(0).message()).isEqualTo(testValue);
}
-
@Test
public void search_activity_log() throws InterruptedException {
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());
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);
}
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);
}
assertThat(count).isEqualTo(max);
}
-
final String test_key = "hello";
final String test_value = "world";
final String testValue = "hello world";
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;
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
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'}]}");
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}");
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
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)
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);
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);
*/
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;
<rules>
<requireFilesSize>
<minsize>84000000</minsize>
- <maxsize>120000000</maxsize>
+ <maxsize>880000000</maxsize>
<files>
<file>${project.build.directory}/sonarqube-${project.version}.zip</file>
</files>
*/
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;
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();