Skip to content

Commit

Permalink
order and deuplicate build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hcoles committed Apr 3, 2024
1 parent acd0075 commit 887a350
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
* Data passed to the listener MutationResultListener factories for use when
Expand Down Expand Up @@ -55,7 +56,10 @@ public ListenerArguments(ResultOutputStrategy outputStrategy,
this.fullMutationMatrix = fullMutationMatrix;
this.data = data;
this.setting = setting;
this.issues = issues;
this.issues = issues.stream()
.distinct()
.sorted()
.collect(Collectors.toList());
}

public ResultOutputStrategy getOutputStrategy() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.pitest.mutationtest;

import org.junit.Test;
import org.pitest.mutationtest.verify.BuildIssue;

import java.util.List;

import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;

public class ListenerArgumentsTest {

@Test
public void removesDuplicateBuildIssues() {
List<BuildIssue> issues = asList(BuildIssue.issue("foo"), BuildIssue.issue("foo"));
ListenerArguments underTest = new ListenerArguments(null, null, null, null, 0, false, null, issues);
assertThat(underTest.issues()).containsExactly(BuildIssue.issue("foo"));
}

@Test
public void ordersBuildIssuesByPriority() {
BuildIssue a = new BuildIssue("foo", null, 5);
BuildIssue b = new BuildIssue("important", null, 0);
BuildIssue c = new BuildIssue("bar", null, 4);
List<BuildIssue> issues = asList(a,b,c);
ListenerArguments underTest = new ListenerArguments(null, null, null, null, 0, false, null, issues);
assertThat(underTest.issues()).containsExactly(b, c, a);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ private void createIndexPages() {

private List<ConvertedIssue> wrap(List<BuildIssue> issues) {
return issues.stream()
.distinct()
.sorted()
.map(ConvertedIssue::new)
.collect(Collectors.toList());
Expand Down

0 comments on commit 887a350

Please sign in to comment.