@Test public void setAttributes_should_not_clear_existing_values() { issue.setAttributes(ImmutableMap.of("1", "one")); assertThat(issue.attribute("1")).isEqualTo("one"); issue.setAttributes(ImmutableMap.of("2", "two")); assertThat(issue.attributes()).containsOnly(entry("1", "one"), entry("2", "two")); issue.setAttributes(null); assertThat(issue.attributes()).containsOnly(entry("1", "one"), entry("2", "two")); }
@Test public void mergeExistingOpenIssue_with_attributes() { DefaultIssue raw = new DefaultIssue() .setNew(true) .setKey("RAW_KEY") .setRuleKey(XOO_X1); DefaultIssue base = new DefaultIssue() .setKey("BASE_KEY") .setResolution(RESOLUTION_FIXED) .setStatus(STATUS_CLOSED) .setSeverity(BLOCKER) .setAttributes(ImmutableMap.of("JIRA", "SONAR-01")); underTest.mergeExistingOpenIssue(raw, base); assertThat(raw.attributes()).containsEntry("JIRA", "SONAR-01"); } }
private void copyFields(DefaultIssue toIssue, DefaultIssue fromIssue) { toIssue.setType(fromIssue.type()); toIssue.setCreationDate(fromIssue.creationDate()); toIssue.setUpdateDate(fromIssue.updateDate()); toIssue.setCloseDate(fromIssue.closeDate()); toIssue.setResolution(fromIssue.resolution()); toIssue.setStatus(fromIssue.status()); toIssue.setAssigneeUuid(fromIssue.assignee()); toIssue.setAuthorLogin(fromIssue.authorLogin()); toIssue.setTags(fromIssue.tags()); toIssue.setAttributes(fromIssue.attributes()); toIssue.setEffort(debtCalculator.calculate(toIssue)); toIssue.setOnDisabledRule(fromIssue.isOnDisabledRule()); toIssue.setSelectedAt(fromIssue.selectedAt()); } }
.setManualSeverity(issue.manualSeverity()) .setAssigneeUuid(issue.assignee()) .setIssueAttributes(KeyValueFormat.format(issue.attributes())) .setAuthorLogin(issue.authorLogin()) .setRuleKey(issue.ruleKey().repository(), issue.ruleKey().rule())
.setProjectUuid(issue.projectUuid()) .setProjectKey(issue.projectKey()) .setIssueAttributes(KeyValueFormat.format(issue.attributes())) .setAuthorLogin(issue.authorLogin()) .setIssueCreationDate(issue.creationDate())
private void copyFields(DefaultIssue toIssue, DefaultIssue fromIssue) { toIssue.setType(fromIssue.type()); toIssue.setCreationDate(fromIssue.creationDate()); toIssue.setUpdateDate(fromIssue.updateDate()); toIssue.setCloseDate(fromIssue.closeDate()); toIssue.setResolution(fromIssue.resolution()); toIssue.setStatus(fromIssue.status()); toIssue.setAssigneeUuid(fromIssue.assignee()); toIssue.setAuthorLogin(fromIssue.authorLogin()); toIssue.setTags(fromIssue.tags()); toIssue.setAttributes(fromIssue.attributes()); toIssue.setEffort(debtCalculator.calculate(toIssue)); toIssue.setOnDisabledRule(fromIssue.isOnDisabledRule()); toIssue.setSelectedAt(fromIssue.selectedAt()); } }
.setManualSeverity(issue.manualSeverity()) .setAssignee(issue.assignee()) .setIssueAttributes(KeyValueFormat.format(issue.attributes())) .setAuthorLogin(issue.authorLogin()) .setRuleKey(issue.ruleKey().repository(), issue.ruleKey().rule())
.setProjectUuid(issue.projectUuid()) .setProjectKey(issue.projectKey()) .setIssueAttributes(KeyValueFormat.format(issue.attributes())) .setAuthorLogin(issue.authorLogin()) .setIssueCreationDate(issue.creationDate())