package org.sonar.server.component;
-import com.google.common.base.Joiner;
-
-import org.apache.commons.collections.CollectionUtils;
-import com.google.common.base.Function;
import com.google.common.base.Function;
+import com.google.common.base.Joiner;
import com.google.common.collect.Collections2;
-import org.sonar.server.exceptions.NotFoundException;
+import org.apache.commons.collections.CollectionUtils;
import org.sonar.api.ServerComponent;
import org.sonar.api.web.UserRole;
import org.sonar.core.component.ComponentDto;
import org.sonar.core.preview.PreviewCache;
import org.sonar.core.resource.ResourceKeyUpdaterDao;
import org.sonar.server.db.DbClient;
+import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.user.UserSession;
import javax.annotation.CheckForNull;
setField(IssueIndexDefinition.FIELD_ISSUE_MODULE_PATH, s);
}
+ @Override
@CheckForNull
public Collection<String> tags() {
return getNullableField(IssueIndexDefinition.FIELD_ISSUE_TAGS);
public class SearchAction extends SearchRequestHandler<IssueQuery, Issue> {
+
public static final String SEARCH_ACTION = "search";
private static final String ACTIONS_EXTRA_FIELD = "actions";
private static final String EXTRA_FIELDS_PARAM = "extra_fields";
+ private static final String INTERNAL_PARAMETER_DISCLAIMER = "This parameter is mostly used by the Issues page, please prefer usage of the componentKeys parameter.";
+
private final IssueChangeDao issueChangeDao;
private final IssueService service;
private final IssueActionsWriter actionsWriter;
.setDescription("Deprecated since 5.1. See componentKeys.");
action.createParam(IssueFilterParameters.COMPONENT_UUIDS)
.setDescription("To retrieve issues associated to a specific list of components (comma-separated list of component UUIDs). " +
- "This parameter is mostly used by the Issues page, please prefer usage of the componentKeys parameter." +
+ INTERNAL_PARAMETER_DISCLAIMER +
"A component can be a project, module, directory or file." +
"If this parameter is set, componentKeys must not be set.")
.setExampleValue("584a89f2-8037-4f7b-b82c-8b45d2d63fb2");
.setDescription("Deprecated since 5.1. See projectKeys");
action.createParam(IssueFilterParameters.PROJECT_KEYS)
.setDescription("To retrieve issues associated to a specific list of projects (comma-separated list of project keys). " +
- "This parameter is mostly used by the Issues page, please prefer usage of the componentKeys parameter." +
+ INTERNAL_PARAMETER_DISCLAIMER +
"If this parameter is set, projectUuids must not be set.")
.setDeprecatedKey(IssueFilterParameters.PROJECTS)
.setExampleValue("org.apache.struts:struts:org.apache.struts.Action");
action.createParam(IssueFilterParameters.PROJECT_UUIDS)
.setDescription("To retrieve issues associated to a specific list of projects (comma-separated list of project UUIDs). " +
- "This parameter is mostly used by the Issues page, please prefer usage of the componentKeys parameter." +
+ INTERNAL_PARAMETER_DISCLAIMER +
"Views are not supported. If this parameter is set, projectKeys must not be set.")
.setExampleValue("7d8749e8-3070-4903-9188-bdd82933bb92");
.setDescription("Deprecated since 5.1. See moduleUuids.");
action.createParam(IssueFilterParameters.MODULE_KEYS)
.setDescription("To retrieve issues associated to a specific list of modules (comma-separated list of module keys). " +
- "This parameter is mostly used by the Issues page, please prefer usage of the componentKeys parameter." +
+ INTERNAL_PARAMETER_DISCLAIMER +
"Views are not supported. If this parameter is set, componentRootUuids must not be set.")
.setDeprecatedKey(IssueFilterParameters.COMPONENT_ROOTS)
.setExampleValue("org.apache.struts:struts");
action.createParam(IssueFilterParameters.MODULE_UUIDS)
.setDescription("To retrieve issues associated to a specific list of components and their sub-components (comma-separated list of component UUIDs). " +
- "This parameter is mostly used by the Issues page, please prefer usage of the componentKeys parameter." +
+ INTERNAL_PARAMETER_DISCLAIMER +
"Views are not supported. If this parameter is set, moduleKeys must not be set.")
.setDeprecatedKey(IssueFilterParameters.COMPONENT_ROOT_UUIDS)
.setExampleValue("7d8749e8-3070-4903-9188-bdd82933bb92");
@Test
public void index_with_index_type_and_id() {
+ esTester.setProfilingLevel(Profiling.Level.FULL);
IndexResponse response = esTester.client().prepareIndex(FakeIndexDefinition.INDEX, FakeIndexDefinition.TYPE)
.setSource(FakeIndexDefinition.newDoc(42))
.get();
@Test
public void fail_if_bad_query() throws Exception {
+ esTester.setProfilingLevel(Profiling.Level.FULL);
+ IndexRequestBuilder requestBuilder = esTester.client().prepareIndex("unknownIndex", "unknownType");
+ try {
+ requestBuilder.get();
+ fail();
+ } catch (Exception e) {
+ assertThat(e).isInstanceOf(IllegalStateException.class);
+ assertThat(e.getMessage()).contains("Fail to execute ES index request for key 'null' on index 'unknownIndex' on type 'unknownType'");
+ }
+ }
+
+ @Test
+ public void fail_if_bad_query_with_basic_profiling() throws Exception {
+ esTester.setProfilingLevel(Profiling.Level.BASIC);
IndexRequestBuilder requestBuilder = esTester.client().prepareIndex("unknownIndex", "unknownType");
try {
requestBuilder.get();
@Test
public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+ esTester.setProfilingLevel(Profiling.Level.FULL);
try {
esTester.client().prepareIndex(FakeIndexDefinition.INDEX, FakeIndexDefinition.TYPE).get("1");
fail();
@Test
public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+ esTester.setProfilingLevel(Profiling.Level.FULL);
try {
esTester.client().prepareIndex(FakeIndexDefinition.INDEX, FakeIndexDefinition.TYPE).get(TimeValue.timeValueMinutes(1));
fail();
@Test
public void do_not_support_execute_method() throws Exception {
+ esTester.setProfilingLevel(Profiling.Level.FULL);
try {
esTester.client().prepareIndex(FakeIndexDefinition.INDEX, FakeIndexDefinition.TYPE).execute();
fail();
import org.sonar.api.utils.Duration;
import org.sonar.core.rule.RuleDto;
+import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
assertThat(dto.getLanguage()).isEqualTo("xoo");
}
+ @Test
+ public void set_tags() {
+ IssueDto dto = new IssueDto();
+ assertThat(dto.getTags()).isEmpty();
+ assertThat(dto.getTagsString()).isNull();
+
+ dto.setTags(Arrays.asList("tag1", "tag2", "tag3"));
+ assertThat(dto.getTags()).containsOnly("tag1", "tag2", "tag3");
+ assertThat(dto.getTagsString()).isEqualTo("tag1,tag2,tag3");
+
+ dto.setTags(Arrays.<String>asList());
+ assertThat(dto.getTags()).isEmpty();
+
+ dto.setTagsString("tag1, tag2 ,,tag3");
+ assertThat(dto.getTags()).containsOnly("tag1", "tag2", "tag3");
+
+ dto.setTagsString(null);
+ assertThat(dto.getTags()).isEmpty();
+
+ dto.setTagsString("");
+ assertThat(dto.getTags()).isEmpty();
+ }
}