-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #516 from jenkinsci/warnings-delta
Add method to compute all the modified lines of a file change
- Loading branch information
Showing
15 changed files
with
99 additions
and
79 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
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
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
30 changes: 12 additions & 18 deletions
30
src/test/java/io/jenkins/plugins/forensics/miner/CodeMetricSeriesBuilderTest.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 |
---|---|---|
@@ -1,29 +1,23 @@ | ||
package io.jenkins.plugins.forensics.miner; | ||
|
||
import java.util.Map; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
import static org.assertj.core.api.Assertions.*; | ||
import static org.assertj.core.data.MapEntry.entry; | ||
import static org.mockito.Mockito.*; | ||
|
||
class CodeMetricSeriesBuilderTest { | ||
|
||
@Test | ||
void shouldComputeRelativeCountStatistics() { | ||
final int totalLinesOfCode = 10; | ||
final int totalChurn = 20; | ||
ForensicsBuildAction forensicsBuildAction = mock(ForensicsBuildAction.class); | ||
when(forensicsBuildAction.getTotalLinesOfCode()).thenReturn(totalLinesOfCode); | ||
when(forensicsBuildAction.getTotalChurn()).thenReturn(totalChurn); | ||
int totalLinesOfCode = 10; | ||
int totalChurn = 20; | ||
|
||
CodeMetricSeriesBuilder codeMetricSeriesBuilder = new CodeMetricSeriesBuilder(); | ||
Map<String, Integer> computedSeries = codeMetricSeriesBuilder.computeSeries(forensicsBuildAction); | ||
var action = mock(ForensicsBuildAction.class); | ||
when(action.getTotalLinesOfCode()).thenReturn(totalLinesOfCode); | ||
when(action.getTotalChurn()).thenReturn(totalChurn); | ||
|
||
assertThat(computedSeries).hasSize(2); | ||
assertThat(computedSeries.get(CodeMetricSeriesBuilder.LOC_KEY)).isEqualTo(totalLinesOfCode); | ||
assertThat(computedSeries.get(CodeMetricSeriesBuilder.CHURN_KEY)).isEqualTo(totalChurn); | ||
assertThat(new CodeMetricSeriesBuilder().computeSeries(action)) | ||
.containsExactly(entry(CodeMetricSeriesBuilder.LOC_KEY, totalLinesOfCode), | ||
entry(CodeMetricSeriesBuilder.CHURN_KEY, totalChurn)); | ||
} | ||
|
||
} | ||
} |
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