}
private void guessAuthor(DefaultIssue issue) {
- if (issue.line() != null) {
+ // issue.authorLogin() can be not-null when old developer cockpit plugin (or other plugin)
+ // is still installed and executed during analysis
+ if (issue.authorLogin() == null && issue.line() != null) {
issue.setAuthorLogin(linesCache.lineAuthor(issue.line()));
}
}
private void autoAssign(DefaultIssue issue) {
- String scmAccount = issue.authorLogin();
- if (scmAccount != null) {
- issue.setAssignee(scmAccountCache.getNullable(scmAccount));
+ // issue.assignee() can be not-null if the issue-assign-plugin is
+ // still installed and executed during analysis
+ if (issue.assignee() == null) {
+ String scmAccount = issue.authorLogin();
+ if (scmAccount != null) {
+ issue.setAssignee(scmAccountCache.getNullable(scmAccount));
+ }
}
}
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
public class IssueComputationTest {
assertThat(Iterators.getOnlyElement(issueCache.traverse()).assignee()).isNull();
}
+ @Test
+ public void do_not_override_author_and_assignee_set_by_old_batch_plugins() throws Exception {
+ issue.setNew(true);
+
+ // these fields were provided during project analysis, for instance
+ // by developer cockpit or issue-assign plugins
+ issue.setAuthorLogin("charlie");
+ issue.setAssignee("cabu");
+
+ process();
+
+ // keep the values, without trying to update them
+ DefaultIssue cachedIssue = Iterators.getOnlyElement(issueCache.traverse());
+ assertThat(cachedIssue.assignee()).isEqualTo("cabu");
+ assertThat(cachedIssue.authorLogin()).isEqualTo("charlie");
+ verifyZeroInteractions(scmAccountCache);
+ }
+
private void process() {
sut.processComponentIssues("FILE_A", Arrays.asList(issue));
sut.afterReportProcessing();