Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JENKINS-49639 No issues remain in case when specified a project path …
…and only changed lines are expected to be commented
  • Loading branch information
aquarellian committed Mar 8, 2018
1 parent 8334eff commit be36d78
Show file tree
Hide file tree
Showing 7 changed files with 272 additions and 206 deletions.
Expand Up @@ -23,40 +23,35 @@ public abstract class AuthenticationConfig extends AbstractDescribableImpl<Authe
* Gerrit http username if overridden (the original one is in Gerrit Trigger settings)
* todo needs to be replaced by Credentials plugin config
* */
@Nonnull
private String username;

/*
* Gerrit http password if overridden (the original one is in Gerrit Trigger settings)
* todo needs to be replaced by Credentials plugin config
* */
@Nonnull
private String password;

public AuthenticationConfig(@Nonnull String username, @Nonnull String password) {
public AuthenticationConfig(String username, String password) {
this.username = username;
this.password = password;
}

@SuppressFBWarnings(value="NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public AuthenticationConfig() {
}

@Nonnull
public String getUsername() {
return username;
}

public void setUsername(@Nonnull String username) {
public void setUsername(String username) {
this.username = username;
}

@Nonnull
public String getPassword() {
return password;
}

public void setPassword(@Nonnull String password) {
public void setPassword(String password) {
this.password = password;
}

Expand Down
Expand Up @@ -28,9 +28,10 @@ private ByChangedLinesPredicate(Map<String, Set<Integer>> allowedFilesAndLines)

@Override
public boolean apply(IssueAdapter issue) {
return allowedFilesAndLines == null
|| allowedFilesAndLines.keySet().contains(issue.getComponent())
&& isLineChanged(issue.getLine(), allowedFilesAndLines.get(issue.getFilepath()));
String filepath = issue.getFilepath();
return allowedFilesAndLines == null // no filename restriction or
|| allowedFilesAndLines.keySet().contains(filepath) // this file was changed and
&& isLineChanged(issue.getLine(), allowedFilesAndLines.get(filepath)); // this line was changed
}

private boolean isLineChanged(Integer line, Set<Integer> changedLines) {
Expand Down
Expand Up @@ -43,14 +43,14 @@ public void testFilterConfig() {
Assert.assertEquals(SEVERITY, fconfig.getSeverity());
}

@Test
@Test(expected = IllegalArgumentException.class)
public void testNoIssuesTitleTemplate() {
ReviewConfig config = new ReviewConfig();
config.setNoIssuesTitleTemplate(null);
Assert.assertEquals(NO_ISSUES_TITLE_TEMPLATE, config.getNoIssuesTitleTemplate());
}

@Test
@Test(expected = IllegalArgumentException.class)
public void testSomeIssuesTitleTemplate() {
ReviewConfig config = new ReviewConfig();
config.setSomeIssuesTitleTemplate(null);
Expand All @@ -64,7 +64,7 @@ public void testIssuesCommentTemplate() {
Assert.assertEquals(ISSUE_COMMENT_TEMPLATE, config.getIssueCommentTemplate());
}

@Test
@Test(expected = IllegalArgumentException.class)
public void testReviewConfig() {
SonarToGerritPublisher publisher = new SonarToGerritPublisher();
publisher.setReviewConfig(null);
Expand All @@ -87,28 +87,28 @@ public void testReviewConfig() {
Assert.assertEquals(ISSUE_COMMENT_TEMPLATE, config.getIssueCommentTemplate());
}

@Test
@Test(expected = IllegalArgumentException.class)
public void testCategory() {
ScoreConfig config = new ScoreConfig();
config.setCategory(null);
Assert.assertEquals(CATEGORY, config.getCategory());
}

@Test
@Test(expected = IllegalArgumentException.class)
public void testNoIssuesScoreScore() {
ScoreConfig config = new ScoreConfig();
config.setNoIssuesScore(null);
Assert.assertEquals(NO_ISSUES_SCORE, config.getNoIssuesScore());
}

@Test
@Test(expected = IllegalArgumentException.class)
public void testSomeIssuesScoreScore() {
ScoreConfig config = new ScoreConfig();
config.setIssuesScore(null);
Assert.assertEquals(SOME_ISSUES_SCORE, config.getIssuesScore());
}

@Test
@Test(expected = IllegalArgumentException.class)
public void testScoreConfig() {
SonarToGerritPublisher publisher = new SonarToGerritPublisher();
publisher.setScoreConfig(null);
Expand All @@ -125,28 +125,28 @@ public void testScoreConfig() {

}

@Test
@Test(expected = IllegalArgumentException.class)
public void testNoIssuesNotificationRecipient() {
NotificationConfig config = new NotificationConfig();
config.setNoIssuesNotificationRecipient(null);
Assert.assertEquals(NO_ISSUES_NOTIFICATION, config.getNoIssuesNotificationRecipient());
}

@Test
@Test(expected = IllegalArgumentException.class)
public void testIssuesNotificationRecipient() {
NotificationConfig config = new NotificationConfig();
config.setCommentedIssuesNotificationRecipient(null);
Assert.assertEquals(ISSUES_NOTIFICATION, config.getCommentedIssuesNotificationRecipient());
}

@Test
@Test(expected = IllegalArgumentException.class)
public void testNegativeScoreNotificationRecipient() {
NotificationConfig config = new NotificationConfig();
config.setNegativeScoreNotificationRecipient(null);
Assert.assertEquals(SCORE_NOTIFICATION, config.getNegativeScoreNotificationRecipient());
}

@Test
@Test(expected = IllegalArgumentException.class)
public void testNotificationConfig() {
SonarToGerritPublisher publisher = new SonarToGerritPublisher();
publisher.setNotificationConfig(null);
Expand All @@ -163,7 +163,7 @@ public void testNotificationConfig() {

}

@Test
@Test(expected = IllegalArgumentException.class)
public void testSonarUrl() {
InspectionConfig config = new InspectionConfig();
config.setServerURL(null);
Expand All @@ -178,7 +178,7 @@ public void testSonarReportPath() {
Assert.assertEquals(SONAR_REPORT_PATH, config.getSonarReportPath());
}

@Test
@Test(expected = IllegalArgumentException.class)
public void testInspectionConfig() {
SonarToGerritPublisher publisher = new SonarToGerritPublisher();
publisher.setInspectionConfig(null);
Expand Down

This file was deleted.

0 comments on commit be36d78

Please sign in to comment.