<foreach item="assignee" index="index" collection="assignees" open="(" separator="," close=")">#{assignee}
</foreach>
</if>
+ <if test="assigned != null">
+ <if test="assigned == true">
+ and i.assignee_login is not null
+ </if>
+ <if test="assigned == false">
+ and i.assignee_login is null
+ </if>
+ </if>
<if test="rules != null and rules.size() > 0">
and (<foreach item="rule" index="index" collection="rules" open="(" separator=" or " close=")">r.plugin_name=#{rule.repository} and r.plugin_rule_key=#{rule.rule}</foreach>)
</if>
assertThat(issues).isEmpty();
}
+ @Test
+ public void should_select_by_assigned() {
+ setupData("shared", "should_select_by_assigned");
+
+ IssueQuery query = IssueQuery.builder().assigned(true).build();
+ List<IssueDto> issues = newArrayList(dao.select(query));
+ assertThat(issues).hasSize(2);
+
+ query = IssueQuery.builder().assigned(false).build();
+ issues = newArrayList(dao.select(query));
+ assertThat(issues).hasSize(1);
+
+ query = IssueQuery.builder().assigned(null).build();
+ issues = newArrayList(dao.select(query));
+ assertThat(issues).hasSize(3);
+ }
+
@Test
public void should_select_all() {
setupData("shared", "should_select_all");
assertThat(results).hasSize(3);
}
-
}
--- /dev/null
+<dataset>
+
+ <!-- rule 500 -->
+ <issues
+ id="100"
+ kee="ABCDE"
+ resource_id="400"
+ rule_id="500"
+ severity="BLOCKER"
+ manual_severity="[false]"
+ manual_issue="[false]"
+ description="[null]"
+ line="200"
+ cost="4.2"
+ status="OPEN"
+ resolution="FIXED"
+ checksum="XXX"
+ user_login="arthur"
+ assignee_login="perceval"
+ author_login="[null]"
+ attributes="JIRA=FOO-1234"
+ created_at="2013-04-16"
+ updated_at="2013-04-16"
+ closed_at="2013-04-16"
+ />
+
+ <issues
+ id="101"
+ kee="ABCDE"
+ resource_id="400"
+ rule_id="500"
+ severity="BLOCKER"
+ manual_severity="[false]"
+ manual_issue="[false]"
+ description="[null]"
+ line="200"
+ cost="4.2"
+ status="OPEN"
+ resolution="FIXED"
+ checksum="XXX"
+ user_login="arthur"
+ assignee_login="perceval"
+ author_login="[null]"
+ attributes="JIRA=FOO-1234"
+ created_at="2013-04-16"
+ updated_at="2013-04-16"
+ closed_at="2013-04-16"
+ />
+
+
+ <!-- rule 501 -->
+ <issues
+ id="102"
+ kee="ABCDE"
+ resource_id="400"
+ rule_id="501"
+ severity="BLOCKER"
+ manual_severity="[false]"
+ manual_issue="[false]"
+ description="[null]"
+ line="200"
+ cost="4.2"
+ status="OPEN"
+ resolution="FIXED"
+ checksum="XXX"
+ user_login="arthur"
+ assignee_login="[null]"
+ author_login="[null]"
+ attributes="JIRA=FOO-1234"
+ created_at="2013-04-16"
+ updated_at="2013-04-16"
+ closed_at="2013-04-16"
+ />
+</dataset>
private final Collection<RuleKey> rules;
private final Collection<String> userLogins;
private final Collection<String> assignees;
+ private final Boolean assigned;
private final Date createdAfter;
private final Date createdBefore;
private final String sort;
this.rules = builder.rules;
this.userLogins = builder.userLogins;
this.assignees = builder.assignees;
+ this.assigned = builder.assigned;
this.createdAfter = builder.createdAfter;
this.createdBefore = builder.createdBefore;
this.sort = builder.sort;
return assignees;
}
+ public Boolean assigned() {
+ return assigned;
+ }
+
public Date createdAfter() {
return createdAfter;
}
private Collection<RuleKey> rules;
private Collection<String> userLogins;
private Collection<String> assignees;
+ private Boolean assigned = null;
private Date createdAfter;
private Date createdBefore;
private String sort;
return this;
}
+ /**
+ * If true, it will return all issues assigned to someone
+ * If false, it will return all issues not assigned to someone
+ */
+ public Builder assigned(Boolean assigned) {
+ this.assigned = assigned;
+ return this;
+ }
+
public Builder createdAfter(Date createdAfter) {
this.createdAfter = createdAfter;
return this;
.rules(Lists.newArrayList(RuleKey.of("squid", "AvoidCycle")))
.userLogins(Lists.newArrayList("crunky"))
.assignees(Lists.newArrayList("gargantua"))
+ .assigned(true)
.createdAfter(new Date())
.createdBefore(new Date())
.sort("assignee")
assertThat(query.componentRoots()).containsOnly("org.struts:core");
assertThat(query.userLogins()).containsOnly("crunky");
assertThat(query.assignees()).containsOnly("gargantua");
+ assertThat(query.assigned()).isTrue();
assertThat(query.rules()).containsOnly(RuleKey.of("squid", "AvoidCycle"));
assertThat(query.createdAfter()).isNotNull();
assertThat(query.createdBefore()).isNotNull();
builder.rules(toRules(props.get("rules")));
builder.userLogins(toStrings(props.get("userLogins")));
builder.assignees(toStrings(props.get("assignees")));
+ builder.assigned(toBoolean(props.get("assigned")));
builder.createdAfter(toDate(props.get("createdAfter")));
builder.createdBefore(toDate(props.get("createdBefore")));
builder.pageSize(toInteger(props.get("pageSize")));
return null;
}
+ Boolean toBoolean(Object o) {
+ if (o instanceof Boolean) {
+ return (Boolean) o;
+ }
+ if (o instanceof String) {
+ return Boolean.parseBoolean((String) o);
+ }
+ return null;
+ }
+
public void start() {
// used to force pico to instantiate the singleton at startup
}
options['statuses'] = ['RESOLVED']
elsif rule_param=='unassigned_issues'
- # FIXME 'assignees' to nil will always return all issues!
- options['assignees'] = nil
+ options['assigned'] = false
# TODO
#elsif rule_param=='unplanned_reviews'
map.put("componentRoots", newArrayList("org.sonar"));
map.put("userLogins", newArrayList("marilyn"));
map.put("assignees", newArrayList("joanna"));
+ map.put("assigned", true);
map.put("createdAfter", "2013-04-16T09:08:24+0200");
map.put("createdBefore", "2013-04-17T09:08:24+0200");
map.put("rules", "squid:AvoidCycle,findbugs:NullReference");
assertThat(query.componentRoots()).containsOnly("org.sonar");
assertThat(query.userLogins()).containsOnly("marilyn");
assertThat(query.assignees()).containsOnly("joanna");
+ assertThat(query.assigned()).isTrue();
assertThat(query.rules()).hasSize(2);
assertThat(query.createdAfter()).isEqualTo(DateUtils.parseDateTime("2013-04-16T09:08:24+0200"));
assertThat(query.createdBefore()).isEqualTo(DateUtils.parseDateTime("2013-04-17T09:08:24+0200"));
return addParam("assignees", s);
}
+ public IssueQuery assigned(Boolean assigned) {
+ params.put("assigned", assigned);
+ return this;
+ }
+
public IssueQuery createdAfter(Date d) {
params.put("createdAfter", EncodingUtils.toQueryParam(d, true));
return this;
IssueQuery query = IssueQuery.create()
.issues("ABCDE", "FGHIJ")
.assignees("arthur", "perceval")
+ .assigned(true)
.components("Action.java", "Filter.java")
.componentRoots("struts")
.resolutions("FIXED", "FALSE-POSITIVE")
.pageSize(5)
.pageIndex(4);
- assertThat(query.urlParams()).hasSize(13);
+ assertThat(query.urlParams()).hasSize(14);
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("components", "Action.java,Filter.java"));
assertThat(query.urlParams()).includes(entry("componentRoots", "struts"));
assertThat(query.urlParams()).includes(entry("resolutions", "FIXED,FALSE-POSITIVE"));