@Override
public void onIssue(Component component, DefaultIssue issue) {
- boolean authorWasSet = false;
if (issue.authorLogin() == null) {
loadScmChangesets(component);
String scmAuthor = guessScmAuthor(issue);
+
if (!Strings.isNullOrEmpty(scmAuthor)) {
issueUpdater.setNewAuthor(issue, scmAuthor, changeContext);
- authorWasSet = true;
}
- }
- if (authorWasSet && issue.assignee() == null) {
- String assigneeLogin = StringUtils.defaultIfEmpty(scmAccountToUser.getNullable(issue.authorLogin()), defaultAssignee.loadDefaultAssigneeLogin());
- issueUpdater.setNewAssignee(issue, assigneeLogin, changeContext);
+
+ if (issue.assignee() == null) {
+ String author = issue.authorLogin() == null ? null : scmAccountToUser.getNullable(issue.authorLogin());
+ String assigneeLogin = StringUtils.defaultIfEmpty(author, defaultAssignee.loadDefaultAssigneeLogin());
+
+ issueUpdater.setNewAssignee(issue, assigneeLogin, changeContext);
+ }
}
}
assertThat(issue.assignee()).isEqualTo("Henry V");
}
+ @Test
+ public void when_noscm_data_is_available_defaultAssignee_should_be_used() throws Exception {
+ DefaultIssue issue = new DefaultIssue().setLine(null);
+
+ when(defaultAssignee.loadDefaultAssigneeLogin()).thenReturn("DefaultAssignee");
+ underTest.onIssue(FILE, issue);
+
+ assertThat(issue.assignee()).isEqualTo("DefaultAssignee");
+ }
+
+
@Test
public void set_last_committer_when_line_is_bigger_than_changeset_size() throws Exception {
addScmUser("john", "John C");