fix javadoc & improve assertions
package io.jenkins.plugins.analysis.warnings;
+import java.io.File;
+
import org.junit.Test;
+import edu.hm.hafner.analysis.Issue;
+import edu.hm.hafner.analysis.Severity;
+
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
+import hudson.FilePath;
+
import io.jenkins.plugins.analysis.core.model.AnalysisResult;
import io.jenkins.plugins.analysis.core.testutil.IntegrationTestWithJenkinsPerSuite;
+import static io.jenkins.plugins.analysis.core.model.AnalysisResultAssert.*;
import static org.assertj.core.api.Assertions.*;
/**
- * Integration test of the SourceControlTable.
+ * Integration test for the use of the warnings-ng plugin together with the timestamper plugin.
*
* @author Fabian Janker
* @author Andreas Pabst
*/
-
public class TimestampPluginITest extends IntegrationTestWithJenkinsPerSuite {
/**
@@ -37,9 +44,15 @@ public class TimestampPluginITest extends IntegrationTestWithJenkinsPerSuite {
AnalysisResult result = scheduleSuccessfulBuild(project);
- assertThat(result.getTotalSize()).isEqualTo(1);
- assertThat(result.getIssues().get(0).getBaseName()).isEqualTo("Test.java");
- assertThat(result.getErrorMessages()).isEmpty();
+ assertThat(result).hasTotalSize(1);
+ assertThat(result).hasNoErrorMessages();
+
+ Issue issue = result.getIssues().get(0);
+ assertThat(new FilePath(new File(issue.getFileName()))).isEqualTo(getWorkspace(project).child("Test.java"));
+ assertThat(issue.getLineStart()).isEqualTo(39);
+ assertThat(issue.getLineEnd()).isEqualTo(39);
+ assertThat(issue.getMessage()).isEqualTo("Test Warning");
+ assertThat(issue.getSeverity()).isEqualTo(Severity.WARNING_NORMAL);
}
/**
@@ -60,9 +73,15 @@ public class TimestampPluginITest extends IntegrationTestWithJenkinsPerSuite {
AnalysisResult result = scheduleSuccessfulBuild(project);
- assertThat(result.getTotalSize()).isEqualTo(1);
- assertThat(result.getIssues().get(0).getBaseName()).isEqualTo("test.c");
- assertThat(result.getErrorMessages()).isEmpty();
+ assertThat(result).hasTotalSize(1);
+ assertThat(result).hasNoErrorMessages();
+
+ Issue issue = result.getIssues().get(0);
+ assertThat(new FilePath(new File(issue.getFileName()))).isEqualTo(getWorkspace(project).child("test.c"));
+ assertThat(issue.getLineStart()).isEqualTo(1);
+ assertThat(issue.getLineEnd()).isEqualTo(1);
+ assertThat(issue.getMessage()).isEqualTo("This is an error.");
+ assertThat(issue.getSeverity()).isEqualTo(Severity.WARNING_HIGH);
}
}
