use of org.sonar.ce.task.projectanalysis.period.Period in project sonarqube by SonarSource.
the class NewLinesRepositoryTest method compute_new_lines_using_scm_info_for_period.
@Test
public void compute_new_lines_using_scm_info_for_period() {
periodHolder.setPeriod(new Period("", null, 1000L));
scmInfoRepository.setScmInfo(FILE.getReportAttributes().getRef(), createChangesets(1100L, 900L, 1000L, 800L));
Optional<Set<Integer>> newLines = repository.getNewLines(FILE);
assertThat(newLines).isPresent();
assertThat(newLines.get()).containsOnly(1);
assertThat(repository.newLinesAvailable()).isTrue();
}
use of org.sonar.ce.task.projectanalysis.period.Period in project sonarqube by SonarSource.
the class NewIssueClassifierTest method isNew_returns_false_for_issue_which_was_new_but_it_is_not_located_on_changed_lines_anymore.
@Test
public void isNew_returns_false_for_issue_which_was_new_but_it_is_not_located_on_changed_lines_anymore() {
periodHolder.setPeriod(new Period(NewCodePeriodType.REFERENCE_BRANCH.name(), "master", null));
Component file = mock(Component.class);
DefaultIssue issue = mock(DefaultIssue.class);
when(file.getType()).thenReturn(Component.Type.FILE);
when(file.getUuid()).thenReturn("fileUuid");
when(newLinesRepository.getNewLines(file)).thenReturn(Optional.of(Set.of(2, 3)));
when(issue.getLocations()).thenReturn(DbIssues.Locations.newBuilder().setTextRange(DbCommons.TextRange.newBuilder().setStartLine(10).setStartOffset(1).setEndLine(10).setEndOffset(2).build()).build());
when(issue.isNewCodeReferenceIssue()).thenReturn(true);
assertThat(newIssueClassifier.isNew(file, issue)).isFalse();
assertThat(newIssueClassifier.isOnBranchUsingReferenceBranch()).isTrue();
assertThat(newIssueClassifier.hasAtLeastOneLocationOnChangedLines(file, issue)).isFalse();
}
use of org.sonar.ce.task.projectanalysis.period.Period in project sonarqube by SonarSource.
the class NewIssueClassifierTest method isNew_returns_true_if_issue_is_on_period.
@Test
public void isNew_returns_true_if_issue_is_on_period() {
periodHolder.setPeriod(new Period(NewCodePeriodType.NUMBER_OF_DAYS.name(), "10", 1000L));
DefaultIssue issue = mock(DefaultIssue.class);
when(issue.creationDate()).thenReturn(new Date(2000L));
assertThat(newIssueClassifier.isNew(mock(Component.class), issue)).isTrue();
verify(issue).creationDate();
verifyNoMoreInteractions(issue);
}
use of org.sonar.ce.task.projectanalysis.period.Period in project sonarqube by SonarSource.
the class NewIssueClassifierTest method isEnabled_returns_true_when_reference_period_present.
@Test
public void isEnabled_returns_true_when_reference_period_present() {
periodHolder.setPeriod(new Period(NewCodePeriodType.REFERENCE_BRANCH.name(), "master", null));
assertThat(newIssueClassifier.isEnabled()).isTrue();
}
use of org.sonar.ce.task.projectanalysis.period.Period in project sonarqube by SonarSource.
the class NewIssueClassifierTest method isNew_returns_false_if_issue_is_not_on_period.
@Test
public void isNew_returns_false_if_issue_is_not_on_period() {
periodHolder.setPeriod(new Period(NewCodePeriodType.NUMBER_OF_DAYS.name(), "10", 1000L));
DefaultIssue issue = mock(DefaultIssue.class);
when(issue.creationDate()).thenReturn(new Date(500L));
assertThat(newIssueClassifier.isNew(mock(Component.class), issue)).isFalse();
verify(issue).creationDate();
verifyNoMoreInteractions(issue);
}
Aggregations