use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class TransitionTest method should_verify_conditions.
@Test
public void should_verify_conditions() {
DefaultIssue issue = new DefaultIssue();
Transition transition = Transition.builder("close").from("OPEN").to("CLOSED").conditions(condition1, condition2).build();
when(condition1.matches(issue)).thenReturn(true);
when(condition2.matches(issue)).thenReturn(false);
assertThat(transition.supports(issue)).isFalse();
when(condition1.matches(issue)).thenReturn(true);
when(condition2.matches(issue)).thenReturn(true);
assertThat(transition.supports(issue)).isTrue();
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class CloseIssuesOnRemovedComponentsVisitorTest method close_issue.
@Test
public void close_issue() throws Exception {
String fileUuid = "FILE1";
String issueUuid = "ABCD";
when(componentsWithUnprocessedIssues.getUuids()).thenReturn(newHashSet(fileUuid));
DefaultIssue issue = new DefaultIssue().setKey(issueUuid);
when(baseIssuesLoader.loadForComponentUuid(fileUuid)).thenReturn(Collections.singletonList(issue));
underTest.visit(ReportComponent.builder(PROJECT, 1).build());
verify(issueLifecycle).doAutomaticTransition(issue);
CloseableIterator<DefaultIssue> issues = issueCache.traverse();
assertThat(issues.hasNext()).isTrue();
DefaultIssue result = issues.next();
assertThat(result.key()).isEqualTo(issueUuid);
assertThat(result.isBeingClosed()).isTrue();
assertThat(result.isOnDisabledRule()).isFalse();
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class EffortAggregatorTest method reliability_effort_is_only_computed_using_bug_issues.
@Test
public void reliability_effort_is_only_computed_using_bug_issues() {
DefaultIssue bugIssue = newBugIssue(10);
// Issues of type CODE SMELL and VULNERABILITY should be ignored
DefaultIssue codeSmellIssue = newCodeSmellIssue(15);
DefaultIssue vulnerabilityIssue = newVulnerabilityIssue(12);
underTest.beforeComponent(FILE);
underTest.onIssue(FILE, bugIssue);
underTest.onIssue(FILE, codeSmellIssue);
underTest.onIssue(FILE, vulnerabilityIssue);
underTest.afterComponent(FILE);
// Only effort of BUG issue is used
assertMeasure(FILE, RELIABILITY_REMEDIATION_EFFORT_KEY, 10L);
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class EffortAggregatorTest method security_effort_is_only_computed_using_code_smell_issues.
@Test
public void security_effort_is_only_computed_using_code_smell_issues() {
DefaultIssue vulnerabilityIssue = newVulnerabilityIssue(10);
// Issues of type BUG and CODE SMELL should be ignored
DefaultIssue bugIssue = newBugIssue(15);
DefaultIssue codeSmellIssue = newCodeSmellIssue(12);
underTest.beforeComponent(FILE);
underTest.onIssue(FILE, vulnerabilityIssue);
underTest.onIssue(FILE, bugIssue);
underTest.onIssue(FILE, codeSmellIssue);
underTest.afterComponent(FILE);
// Only effort of VULNERABILITY issue is used
assertMeasure(FILE, SECURITY_REMEDIATION_EFFORT_KEY, 10L);
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class EffortAggregatorTest method sum_maintainability_effort_of_unresolved_issues.
@Test
public void sum_maintainability_effort_of_unresolved_issues() {
DefaultIssue unresolved1 = newCodeSmellIssue(10);
DefaultIssue unresolved2 = newCodeSmellIssue(30);
DefaultIssue unresolvedWithoutEffort = newCodeSmellIssueWithoutEffort();
DefaultIssue resolved = newCodeSmellIssue(50).setResolution(RESOLUTION_FIXED);
underTest.beforeComponent(FILE);
underTest.onIssue(FILE, unresolved1);
underTest.onIssue(FILE, unresolved2);
underTest.onIssue(FILE, unresolvedWithoutEffort);
underTest.onIssue(FILE, resolved);
underTest.afterComponent(FILE);
// total maintainability effort
assertMeasure(FILE, TECHNICAL_DEBT_KEY, 10L + 30L);
}
Aggregations