-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
record history before result interceptor manipulation
- Loading branch information
Showing
9 changed files
with
106 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
pitest-entry/src/main/java/org/pitest/mutationtest/incremental/HistoryResultInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.pitest.mutationtest.incremental; | ||
|
||
import org.pitest.mutationtest.ClassMutationResults; | ||
import org.pitest.mutationtest.History; | ||
import org.pitest.mutationtest.MutationResultInterceptor; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Records results for history before other interceptors are applied. Artificially | ||
* added via hacky hard coding. | ||
*/ | ||
public class HistoryResultInterceptor implements MutationResultInterceptor { | ||
|
||
private final History history; | ||
|
||
public HistoryResultInterceptor(History historyStore) { | ||
this.history = historyStore; | ||
} | ||
|
||
@Override | ||
public Collection<ClassMutationResults> modify(Collection<ClassMutationResults> results) { | ||
results.stream() | ||
.flatMap(c -> c.getMutations().stream()) | ||
.forEach(this.history::recordResult); | ||
return results; | ||
} | ||
|
||
@Override | ||
public int priority() { | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...entry/src/test/java/org/pitest/mutationtest/incremental/HistoryResultInterceptorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.pitest.mutationtest.incremental; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.MockitoAnnotations; | ||
import org.pitest.mutationtest.ClassMutationResults; | ||
import org.pitest.mutationtest.DetectionStatus; | ||
import org.pitest.mutationtest.History; | ||
import org.pitest.mutationtest.MutationResult; | ||
import org.pitest.mutationtest.MutationStatusTestPair; | ||
import org.pitest.mutationtest.report.MutationTestResultMother; | ||
|
||
import java.util.Collection; | ||
|
||
import static java.util.Arrays.asList; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.verify; | ||
|
||
public class HistoryResultInterceptorTest { | ||
private History store = Mockito.mock(History.class); | ||
private HistoryResultInterceptor testee = new HistoryResultInterceptor(this.store); | ||
|
||
@Test | ||
public void recordsMutationResults() { | ||
final MutationResult mr = makeResult(); | ||
final ClassMutationResults metaData = MutationTestResultMother | ||
.createClassResults(mr); | ||
Collection<ClassMutationResults> mutants = asList(metaData); | ||
Collection<ClassMutationResults> actual = this.testee.modify(mutants); | ||
verify(this.store).recordResult(mr); | ||
assertThat(actual).isSameAs(mutants); | ||
} | ||
|
||
|
||
private MutationResult makeResult() { | ||
return new MutationResult( | ||
MutationTestResultMother.createDetails(), MutationStatusTestPair.notAnalysed(0, | ||
DetectionStatus.KILLED)); | ||
} | ||
|
||
} |