public Builder setResolution(@Nullable String resolution) { this.resolution = validateResolution(resolution); return this; }
@Test public void create_issue() throws Exception { Issue issue = new TestIssue.Builder() .setKey("ABCD") .setRuleKey(RuleKey.of("xoo", "S01")) .setSeverity(Severity.BLOCKER) .setStatus(org.sonar.api.issue.Issue.STATUS_RESOLVED) .setResolution(org.sonar.api.issue.Issue.RESOLUTION_FIXED) .setEffort(Duration.create(10L)) .setType(RuleType.BUG) .build(); assertThat(issue.key()).isEqualTo("ABCD"); assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("xoo", "S01")); assertThat(issue.severity()).isEqualTo(Severity.BLOCKER); assertThat(issue.status()).isEqualTo(org.sonar.api.issue.Issue.STATUS_RESOLVED); assertThat(issue.resolution()).isEqualTo(org.sonar.api.issue.Issue.RESOLUTION_FIXED); assertThat(issue.effort()).isEqualTo(Duration.create(10L)); }
public Builder setStatus(String status) { this.status = validateStatus(status); return this; }
public Builder setRuleKey(RuleKey ruleKey) { this.ruleKey = validateRuleKey(ruleKey); return this; }
public Builder setSeverity(String severity) { this.severity = validateSeverity(severity); return this; }
public Builder setKey(String key) { this.key = validateKey(key); return this; }
public Builder setResolution(@Nullable String resolution) { this.resolution = validateResolution(resolution); return this; }
/** * @since 5.5 */ public Builder setType(RuleType type) { this.type = validateType(type); return this; }
public Issue build() { validateKey(key); validateResolution(resolution); validateSeverity(severity); validateStatus(status); validateRuleKey(ruleKey); validateType(type); return new TestIssue(this); } }
@Test public void get_issues() throws Exception { Issue issue = new TestIssue.Builder() .setKey("ABCD") .setRuleKey(RuleKey.of("xoo", "S01")) .setSeverity(Severity.BLOCKER) .setStatus(org.sonar.api.issue.Issue.STATUS_RESOLVED) .setResolution(org.sonar.api.issue.Issue.RESOLUTION_FIXED) .setEffort(Duration.create(10L)) .setType(RuleType.BUG) .build(); underTest.setIssues(Arrays.asList(issue)); assertThat(underTest.getIssues()).hasSize(1); } }
public Builder setStatus(String status) { this.status = validateStatus(status); return this; }
public Builder setSeverity(String severity) { this.severity = validateSeverity(severity); return this; }
@Test public void fail_with_IAE_when_building_issue_with_invalid_status() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("status 'unknown' is invalid"); new TestIssue.Builder() .setKey("ABCD") .setRuleKey(RuleKey.of("xoo", "S01")) .setSeverity(Severity.BLOCKER) .setStatus("unknown") .setResolution(org.sonar.api.issue.Issue.RESOLUTION_FIXED) .setType(RuleType.BUG) .build(); } }
public Builder setRuleKey(RuleKey ruleKey) { this.ruleKey = validateRuleKey(ruleKey); return this; }
@Test public void fail_with_NPE_when_creating_issue_with_null_severity() throws Exception { thrown.expect(NullPointerException.class); thrown.expectMessage("severity cannot be null"); new TestIssue.Builder().setSeverity(null); }
@Test public void fail_with_IAE_when_building_issue_with_invalid_severity() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("severity 'unknown' is invalid"); new TestIssue.Builder() .setKey("ABCD") .setRuleKey(RuleKey.of("xoo", "S01")) .setSeverity("unknown") .setStatus(org.sonar.api.issue.Issue.STATUS_RESOLVED) .setResolution(org.sonar.api.issue.Issue.RESOLUTION_FIXED) .setType(RuleType.BUG) .build(); }
@Test public void fail_with_NPE_when_building_issue_without_key() throws Exception { thrown.expect(NullPointerException.class); thrown.expectMessage("key cannot be null"); new TestIssue.Builder() .setRuleKey(RuleKey.of("xoo", "S01")) .setSeverity(Severity.BLOCKER) .setStatus(org.sonar.api.issue.Issue.STATUS_RESOLVED) .setResolution(org.sonar.api.issue.Issue.RESOLUTION_FIXED) .setType(RuleType.BUG) .build(); }
/** * @since 5.5 */ public Builder setType(RuleType type) { this.type = validateType(type); return this; }
@Test public void fail_with_NPE_when_creating_issue_with_null_rule_key() throws Exception { thrown.expect(NullPointerException.class); thrown.expectMessage("ruleKey cannot be null"); new TestIssue.Builder().setRuleKey(null); }
@Test public void fail_with_NPE_when_building_issue_without_status() throws Exception { thrown.expect(NullPointerException.class); thrown.expectMessage("status cannot be null"); new TestIssue.Builder() .setKey("ABCD") .setRuleKey(RuleKey.of("xoo", "S01")) .setSeverity(Severity.BLOCKER) .setResolution(org.sonar.api.issue.Issue.RESOLUTION_FIXED) .setType(RuleType.BUG) .build(); }