Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.jenkins.plugins.forensics.miner;

import java.util.Map;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;

class RelativeCountCommitStatisticsSeriesBuilderTest {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@Test
void computeSeries() {
RelativeCountCommitStatisticsSeriesBuilder relativeCountCommitStatisticsSeriesBuilder = new RelativeCountCommitStatisticsSeriesBuilder();
CommitStatisticsBuildAction commitStatisticsBuildActionStub = mock(CommitStatisticsBuildAction.class);
CommitStatistics commitStatistics = mock(CommitStatistics.class);
when(commitStatisticsBuildActionStub.getCommitStatistics()).thenReturn(commitStatistics);
when(commitStatistics.getCommitCount()).thenReturn(7);
when(commitStatistics.getAuthorCount()).thenReturn(11);
when(commitStatistics.getFilesCount()).thenReturn(17);

Map<String, Integer> result = relativeCountCommitStatisticsSeriesBuilder.computeSeries(
commitStatisticsBuildActionStub);

assertThat(result.get("commits")).isEqualTo(7);
assertThat(result.get("authors")).isEqualTo(11);
assertThat(result.get("files")).isEqualTo(17);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the constants of the builder

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simpler way would be:

assertThat(result)
                 .containsEntry(COMMITS, 7)
                 .containsEntry(AUTHORS, 11);

}
}