<foreach item="component" index="index" collection="query.components()" open="(" separator=" or " close=")">project_component.kee=#{component}
</foreach>
</if>
- <if test="query.rules().size()>0">
- inner join rules r on r.id=i.rule_id and (<foreach item="rule" index="index" collection="query.rules()" open="(" separator=" or " close=")">
- r.plugin_name=#{rule.repository} and r.plugin_rule_key=#{rule.rule}</foreach>)
+ <if test="query.rules().size()>0 or query.languages().size()>0">
+ inner join rules r on r.id=i.rule_id
+ <if test="query.rules().size()>0">
+ and (<foreach item="rule" index="index" collection="query.rules()" open="(" separator=" or " close=")">
+ r.plugin_name=#{rule.repository} and r.plugin_rule_key=#{rule.rule}</foreach>)
+ </if>
+ <if test="query.languages().size()>0">
+ and (<foreach item="language" index="index" collection="query.languages()" open="(" separator=" or " close=")">
+ r.language=#{language}</foreach>)
+ </if>
</if>
<where>
<if test="query.issueKeys().size()>0">
assertThat(dao.selectIssueIds(query)).isEmpty();
}
+ @Test
+ public void select_by_languages() {
+ setupData("shared", "select_by_languages");
+
+ IssueQuery query = IssueQuery.builder().languages(newArrayList("java")).requiredRole("user").build();
+ assertThat(dao.selectIssueIds(query)).hasSize(2);
+
+ query = IssueQuery.builder().languages(newArrayList("java", "xoo")).requiredRole("user").build();
+ assertThat(dao.selectIssueIds(query)).hasSize(3);
+
+ query = IssueQuery.builder().languages(newArrayList("Other")).requiredRole("user").build();
+ assertThat(dao.selectIssueIds(query)).isEmpty();
+ }
+
@Test
public void should_select_issues_for_authorized_projects() {
setupData("should_select_issues_for_authorized_projects");
--- /dev/null
+<!--
+ ~ SonarQube, open source software quality management tool.
+ ~ Copyright (C) 2008-2014 SonarSource
+ ~ mailto:contact AT sonarsource DOT com
+ ~
+ ~ SonarQube 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.
+ ~
+ ~ SonarQube 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.
+ -->
+
+<dataset>
+
+ <!-- language Java -->
+ <issues
+ id="100"
+ kee="ABCDE-1"
+ component_id="401"
+ root_component_id="399"
+ rule_id="500"
+ severity="BLOCKER"
+ manual_severity="[false]"
+ message="[null]"
+ line="200"
+ effort_to_fix="4.2"
+ status="OPEN"
+ resolution="FIXED"
+ checksum="XXX"
+ reporter="arthur"
+ assignee="perceval"
+ author_login="[null]"
+ issue_attributes="JIRA=FOO-1234"
+ issue_creation_date="2013-04-16"
+ issue_update_date="2013-04-16"
+ issue_close_date="2013-04-16"
+ created_at="2013-04-16"
+ updated_at="2013-04-16"
+ />
+
+ <issues
+ id="101"
+ kee="ABCDE-2"
+ component_id="401"
+ root_component_id="399"
+ rule_id="500"
+ severity="BLOCKER"
+ manual_severity="[false]"
+ message="[null]"
+ line="200"
+ effort_to_fix="4.2"
+ status="OPEN"
+ resolution="FIXED"
+ checksum="XXX"
+ reporter="arthur"
+ assignee="perceval"
+ author_login="[null]"
+ issue_attributes="JIRA=FOO-1234"
+ issue_creation_date="2013-04-16"
+ issue_update_date="2013-04-16"
+ issue_close_date="2013-04-16"
+ created_at="2013-04-16"
+ updated_at="2013-04-16"
+ />
+
+
+ <!-- language Xoo -->
+ <issues
+ id="102"
+ kee="ABCDE-3"
+ component_id="401"
+ root_component_id="399"
+ rule_id="501"
+ severity="BLOCKER"
+ manual_severity="[false]"
+ message="[null]"
+ line="200"
+ effort_to_fix="4.2"
+ status="OPEN"
+ resolution="FIXED"
+ checksum="XXX"
+ reporter="arthur"
+ assignee="perceval"
+ author_login="[null]"
+ issue_attributes="JIRA=FOO-1234"
+ issue_creation_date="2013-04-16"
+ issue_update_date="2013-04-16"
+ issue_close_date="2013-04-16"
+ created_at="2013-04-16"
+ updated_at="2013-04-16"
+ />
+
+</dataset>
<snapshots id="102" project_id="401" root_snapshot_id="100" parent_snapshot_id="101" root_project_id="399" path="100.101." islast="[true]" />
<snapshots id="103" project_id="402" root_snapshot_id="100" parent_snapshot_id="101" root_project_id="399" path="100.101." islast="[true]" />
- <rules id="500" plugin_rule_key="AvoidCycle" plugin_name="squid" />
- <rules id="501" plugin_rule_key="NullRef" plugin_name="squid" />
+ <rules id="500" plugin_rule_key="AvoidCycle" plugin_name="squid" language="java" />
+ <rules id="501" plugin_rule_key="NullRef" plugin_name="squid" language="xoo" />
</dataset>
private final Collection<String> actionPlans;
private final Collection<String> reporters;
private final Collection<String> assignees;
+ private final Collection<String> languages;
private final Boolean assigned;
private final Boolean planned;
private final Boolean resolved;
this.actionPlans = defaultCollection(builder.actionPlans);
this.reporters = defaultCollection(builder.reporters);
this.assignees = defaultCollection(builder.assignees);
+ this.languages = defaultCollection(builder.languages);
this.assigned = builder.assigned;
this.planned = builder.planned;
this.resolved = builder.resolved;
public Collection<String> assignees() {
return assignees;
}
+ public Collection<String> languages() {
+ return languages;
+ }
@CheckForNull
public Boolean assigned() {
private Collection<String> actionPlans;
private Collection<String> reporters;
private Collection<String> assignees;
+ private Collection<String> languages;
private Boolean assigned = null;
private Boolean planned = null;
private Boolean resolved = null;
return this;
}
+ public Builder languages(@Nullable Collection<String> l) {
+ this.languages = l;
+ return this;
+ }
+
/**
* If true, it will return all issues assigned to someone
* If false, it will return all issues not assigned to someone
.actionPlans(newArrayList("AP1", "AP2"))
.reporters(newArrayList("crunky"))
.assignees(newArrayList("gargantua"))
+ .languages(newArrayList("xoo"))
.assigned(true)
.hideRules(true)
.createdAfter(new Date())
assertThat(query.componentRoots()).containsOnly("org.struts:core");
assertThat(query.reporters()).containsOnly("crunky");
assertThat(query.assignees()).containsOnly("gargantua");
+ assertThat(query.languages()).containsOnly("xoo");
assertThat(query.assigned()).isTrue();
assertThat(query.hideRules()).isTrue();
assertThat(query.rules()).containsOnly(RuleKey.of("squid", "AvoidCycle"));
.resolutions(null)
.rules(null)
.severities(null)
+ .languages(null)
.build();
assertThat(query.issueKeys()).isEmpty();
assertThat(query.components()).isEmpty();
assertThat(query.resolutions()).isEmpty();
assertThat(query.rules()).isEmpty();
assertThat(query.severities()).isEmpty();
+ assertThat(query.languages()).isEmpty();
}
@Test
assertThat(query.resolutions()).isEmpty();
assertThat(query.rules()).isEmpty();
assertThat(query.severities()).isEmpty();
+ assertThat(query.languages()).isEmpty();
assertThat(query.assigned()).isNull();
assertThat(query.createdAfter()).isNull();
assertThat(query.createdBefore()).isNull();
.actionPlans(RubyUtils.toStrings(props.get(IssueFilterParameters.ACTION_PLANS)))
.reporters(RubyUtils.toStrings(props.get(IssueFilterParameters.REPORTERS)))
.assignees(RubyUtils.toStrings(props.get(IssueFilterParameters.ASSIGNEES)))
+ .languages(RubyUtils.toStrings(props.get(IssueFilterParameters.LANGUAGES)))
.assigned(RubyUtils.toBoolean(props.get(IssueFilterParameters.ASSIGNED)))
.planned(RubyUtils.toBoolean(props.get(IssueFilterParameters.PLANNED)))
.hideRules(RubyUtils.toBoolean(props.get(IssueFilterParameters.HIDE_RULES)))
public static final String ACTION_PLANS = "actionPlans";
public static final String REPORTERS = "reporters";
public static final String ASSIGNEES = "assignees";
+ public static final String LANGUAGES = "languages";
public static final String ASSIGNED = "assigned";
public static final String PLANNED = "planned";
public static final String HIDE_RULES = "hideRules";
public static final String ASC = "asc";
public static final List<String> ALL = ImmutableList.of(ISSUES, SEVERITIES, STATUSES, RESOLUTIONS, RESOLVED, COMPONENTS, COMPONENT_ROOTS, RULES, ACTION_PLANS, REPORTERS,
- ASSIGNEES, ASSIGNED, PLANNED, HIDE_RULES, CREATED_AT, CREATED_AFTER, CREATED_BEFORE, PAGE_SIZE, PAGE_INDEX, SORT, ASC);
+ ASSIGNEES, LANGUAGES, ASSIGNED, PLANNED, HIDE_RULES, CREATED_AT, CREATED_AFTER, CREATED_BEFORE, PAGE_SIZE, PAGE_INDEX, SORT, ASC);
public static final List<String> ALL_WITHOUT_PAGINATION = newArrayList(Iterables.filter(ALL, new Predicate<String>() {
@Override
map.put("componentRoots", newArrayList("org.sonar"));
map.put("reporters", newArrayList("marilyn"));
map.put("assignees", newArrayList("joanna"));
+ map.put("languages", newArrayList("xoo"));
map.put("assigned", true);
map.put("planned", true);
map.put("hideRules", true);
assertThat(query.componentRoots()).containsOnly("org.sonar");
assertThat(query.reporters()).containsOnly("marilyn");
assertThat(query.assignees()).containsOnly("joanna");
+ assertThat(query.languages()).containsOnly("xoo");
assertThat(query.assigned()).isTrue();
assertThat(query.planned()).isTrue();
assertThat(query.hideRules()).isTrue();
}
@Test
- public void should_parse_list_of_rules() {
+ public void parse_list_of_rules() {
assertThat(PublicRubyIssueService.toRules(null)).isNull();
assertThat(PublicRubyIssueService.toRules("")).isEmpty();
assertThat(PublicRubyIssueService.toRules("squid:AvoidCycle")).containsOnly(RuleKey.of("squid", "AvoidCycle"));
}
@Test
- public void should_start() throws Exception {
+ public void start() throws Exception {
facade.start();
// nothing is done
verifyZeroInteractions(finder);
public IssueQuery assignees(String... s) {
return addParam("assignees", s);
}
+ public IssueQuery languages(String... s) {
+ return addParam("languages", s);
+ }
public IssueQuery assigned(Boolean assigned) {
params.put("assigned", assigned);
.statuses("OPEN", "CLOSED")
.severities("BLOCKER", "INFO")
.reporters("login1", "login2")
+ .languages("xoo", "java")
.createdAt(df.parse("2015-01-02T05:59:50:50"))
.createdBefore(df.parse("2015-12-13T05:59:50"))
.createdAfter(df.parse("2012-01-23T13:40:50"))
.pageSize(5)
.pageIndex(4);
- assertThat(query.urlParams()).hasSize(21);
+ assertThat(query.urlParams()).hasSize(22);
assertThat(query.urlParams()).includes(entry("issues", "ABCDE,FGHIJ"));
assertThat(query.urlParams()).includes(entry("assignees", "arthur,perceval"));
assertThat(query.urlParams()).includes(entry("assigned", true));
assertThat(query.urlParams()).includes(entry("statuses", "OPEN,CLOSED"));
assertThat(query.urlParams()).includes(entry("severities", "BLOCKER,INFO"));
assertThat(query.urlParams()).includes(entry("reporters", "login1,login2"));
+ assertThat(query.urlParams()).includes(entry("languages", "xoo,java"));
assertThat((String)query.urlParams().get("createdBefore")).startsWith("2015-12-13T05:59:50");
assertThat((String)query.urlParams().get("createdAfter")).startsWith("2012-01-23T13:40:50");
assertThat((String)query.urlParams().get("createdAt")).startsWith("2015-01-02T05:59:50");