diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2020-08-17 16:10:03 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-08-25 20:06:35 +0000 |
commit | 60c64b2c9f95bb52d070758fa88a3881ae69b5e7 (patch) | |
tree | 25e13b5141a39abcdb4c4a618b5fb5d67c50e602 /sonar-plugin-api | |
parent | 44dca753dbe146624059f8ac076433f403882487 (diff) | |
download | sonarqube-60c64b2c9f95bb52d070758fa88a3881ae69b5e7.tar.gz sonarqube-60c64b2c9f95bb52d070758fa88a3881ae69b5e7.zip |
SONAR-13766 PostProjectAnalysisTask's 'description' is a breaking change
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java | 10 | ||||
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTest.java | 19 |
2 files changed, 15 insertions, 14 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java index 5f1b61ec978..0f581e4d603 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java @@ -46,19 +46,25 @@ public interface PostProjectAnalysisTask { * A short description or name for the task. * <p> * This will be used (but not limited to) in logs reporting the execution of the task. + * @since 8.0 */ - String getDescription(); + default String getDescription() { + return this.getClass().getSimpleName(); + } /** * This method is called whenever the processing of a Project analysis has finished, whether successfully or not. * - * @deprecated implement {@link #finished(Context)} instead + * @deprecated in 8.0. Implement {@link #finished(Context)} instead */ @Deprecated default void finished(ProjectAnalysis analysis) { throw new IllegalStateException("Provide an implementation of method finished(Context)"); } + /** + * @since 8.0 + */ default void finished(Context context) { finished(context.getProjectAnalysis()); } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTest.java index 0ff27846495..f14035ef2f7 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTest.java @@ -25,7 +25,6 @@ import org.sonar.api.ce.posttask.PostProjectAnalysisTask.Context; import org.sonar.api.ce.posttask.PostProjectAnalysisTask.ProjectAnalysis; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -35,18 +34,14 @@ public class PostProjectAnalysisTaskTest { private final ProjectAnalysis projectAnalysis = Mockito.mock(ProjectAnalysis.class); @Test - public void default_implementation_of_finished_ProjectAnalysis_throws_ISE() { - PostProjectAnalysisTask underTest = () -> { - throw new UnsupportedOperationException("getDescription not implemented"); - }; + public void default_implementation_of_finished_ProjectAnalysis_returns_class_name() { + PostProjectAnalysisTask underTest = new PostTask(); + + assertThat(underTest.getDescription()).isEqualTo("PostTask"); + } + + private static class PostTask implements PostProjectAnalysisTask { - try { - underTest.finished(projectAnalysis); - fail("should have thrown an ISE"); - } catch (IllegalStateException e) { - assertThat(e.getMessage()).isEqualTo("Provide an implementation of method finished(Context)"); - Mockito.verifyZeroInteractions(projectAnalysis); - } } @Test |