Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -17,6 +17,7 @@ public enum GeneralOption implements ConfigurationOption {

MESSAGE_COMMENT_FORMAT("message.commentFormat", "Sputnik comment format. {0}: reporter, {1}: level, {2}: message", "[{0}] {1}: {2}"),
MESSAGE_PROBLEM_FORMAT("message.problemFormat", "Sputnik problem format. {0}: reporter, {1}: message", "There is a problem with {0}: {1}"),
MESSAGE_PASSING_COMMENT_ENABLED("message.passingCommentEnabled", "Passing Comment enabled", "true"),
MESSAGE_SCORE_PASSING_COMMENT("message.scorePassingComment", "Comment when no errors are found", "Perfect!"),

CONNECTOR_TYPE("connector.type", "Connector: <stash|gerrit|github|saas|local>", ConnectorType.GERRIT.getName()),
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/pl/touk/sputnik/engine/VisitorBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public List<AfterReviewVisitor> buildAfterReviewVisitors(@Nonnull Configuration

addCommentVisitor(afterReviewVisitors, configuration, connectorFacade);

String passingComment = configuration.getProperty(GeneralOption.MESSAGE_SCORE_PASSING_COMMENT);
String passingComment= null;
if (configuration.getProperty(GeneralOption.MESSAGE_PASSING_COMMENT_ENABLED))
passingComment = configuration.getProperty(GeneralOption.MESSAGE_SCORE_PASSING_COMMENT);
afterReviewVisitors.add(new SummaryMessageVisitor(passingComment));

int maxNumberOfComments = NumberUtils.toInt(configuration.getProperty(GeneralOption.MAX_NUMBER_OF_COMMENTS), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public void afterReview(@NotNull Review review) {

private void addSummaryMessage(Review review) {
String summaryMessage = getSummaryMessage(review);
if (summaryMessage == null) return;

log.info("Adding summary message to review: {}", summaryMessage);
review.getMessages().add(summaryMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ void shouldAddPerfectMessageIfThereAreNoViolationsFound() {
assertThat(review.getMessages()).containsOnly("Perfect");
}

@Test
void shouldNotAddPerfectMessageIfThereAreNoViolationsFound() {
when(review.getTotalViolationCount()).thenReturn(0L);

noPerfectSummaryMessageVisitor.afterReview(review);

assertThat(review.getMessages()).isEmpty();
}

@Test
void shouldAddProblemMessagesPerfectMessageIfThereAreNoViolationsFound() {
when(review.getTotalViolationCount()).thenReturn(8L);
Expand Down