diff options
author | Lukasz Jarocki <lukasz.jarocki@sonarsource.com> | 2021-06-07 13:38:27 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-06-08 20:07:10 +0000 |
commit | 8b49d15421715159733e1401d5c3247670556573 (patch) | |
tree | 2c4b2d9b5a0f4d0448d11f23062e0ceb614291ac /sonar-plugin-api | |
parent | c8683ffc825f59940f534913ae8b9cece30ea8e0 (diff) | |
download | sonarqube-8b49d15421715159733e1401d5c3247670556573.tar.gz sonarqube-8b49d15421715159733e1401d5c3247670556573.zip |
SONAR-14851 Report Quality Gate status on branches in GitHub
Diffstat (limited to 'sonar-plugin-api')
3 files changed, 8 insertions, 111 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 072671e3882..50cf9c5810b 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 @@ -125,28 +125,6 @@ public interface PostProjectAnalysisTask { QualityGate getQualityGate(); /** - * Date of the analysis. - * <p> - * This date is the same as the date of the project analysis report and the snapshot. - * - * @deprecated use {@link #getAnalysis().getDate()} instead. When {@link #getAnalysis()} returns - * {@link Optional#empty() empty}, the current date will be returned. - */ - @Deprecated - Date getDate(); - - /** - * Date of the analysis. - * <p> - * This date is the same as the date of the project analysis report and therefore as the analysis in DB. It can be - * missing when the status of the task is {@link org.sonar.api.ce.posttask.CeTask.Status#FAILED FAILED}. - * </p> - * @deprecated use {@link #getAnalysis().getDate()} instead - */ - @Deprecated - Optional<Date> getAnalysisDate(); - - /** * Analysis containing the UUID of the analysis and the date * * <p> diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java index 96508381c4b..a15aaa423bd 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java @@ -98,8 +98,6 @@ public class PostProjectAnalysisTaskTester { private static final String NAME_CAN_NOT_BE_NULL = "name cannot be null"; private final PostProjectAnalysisTask underTest; - @Nullable - private Organization organization; @CheckForNull private CeTask ceTask; @CheckForNull @@ -128,10 +126,6 @@ public class PostProjectAnalysisTaskTester { /** * @since 7.0 */ - public static OrganizationBuilder newOrganizationBuilder() { - return new OrganizationBuilder(); - } - public static CeTaskBuilder newCeTaskBuilder() { return new CeTaskBuilder(); } @@ -156,14 +150,6 @@ public class PostProjectAnalysisTaskTester { return new ScannerContextBuilder(); } - /** - * @since 7.0 - */ - public PostProjectAnalysisTaskTester withOrganization(@Nullable Organization organization) { - this.organization = organization; - return this; - } - public PostProjectAnalysisTaskTester withCeTask(CeTask ceTask) { this.ceTask = requireNonNull(ceTask, CE_TASK_CAN_NOT_BE_NULL); return this; @@ -228,7 +214,6 @@ public class PostProjectAnalysisTaskTester { } PostProjectAnalysisTask.ProjectAnalysis projectAnalysis = new ProjectAnalysisBuilder() - .setOrganization(organization) .setCeTask(ceTask) .setProject(project) .setBranch(branch) @@ -271,51 +256,6 @@ public class PostProjectAnalysisTaskTester { return stats; } - public static final class OrganizationBuilder { - @CheckForNull - private String name; - @CheckForNull - private String key; - - private OrganizationBuilder() { - // prevents instantiation - } - - public OrganizationBuilder setName(String name) { - this.name = requireNonNull(name, NAME_CAN_NOT_BE_NULL); - return this; - } - - public OrganizationBuilder setKey(String key) { - this.key = requireNonNull(key, KEY_CAN_NOT_BE_NULL); - return this; - } - - public Organization build() { - requireNonNull(this.name, NAME_CAN_NOT_BE_NULL); - requireNonNull(this.key, KEY_CAN_NOT_BE_NULL); - return new Organization() { - @Override - public String getName() { - return name; - } - - @Override - public String getKey() { - return key; - } - - @Override - public String toString() { - return "Organization{" + - "name='" + name + '\'' + - ", key='" + key + '\'' + - '}'; - } - }; - } - } - public static final class CeTaskBuilder { private static final String ID_CAN_NOT_BE_NULL = "id cannot be null"; @@ -727,7 +667,6 @@ public class PostProjectAnalysisTaskTester { } public static final class ProjectAnalysisBuilder { - private Organization organization; private CeTask ceTask; private Project project; private Branch branch; @@ -740,11 +679,6 @@ public class PostProjectAnalysisTaskTester { // prevents instantiation outside PostProjectAnalysisTaskTester } - public ProjectAnalysisBuilder setOrganization(@Nullable Organization organization) { - this.organization = organization; - return this; - } - public ProjectAnalysisBuilder setCeTask(CeTask ceTask) { this.ceTask = ceTask; return this; @@ -784,7 +718,7 @@ public class PostProjectAnalysisTaskTester { return new PostProjectAnalysisTask.ProjectAnalysis() { @Override public Optional<Organization> getOrganization() { - return Optional.ofNullable(organization); + return Optional.empty(); } @Override @@ -809,16 +743,6 @@ public class PostProjectAnalysisTaskTester { } @Override - public Date getDate() { - return date; - } - - @Override - public Optional<Date> getAnalysisDate() { - return getAnalysis().map(Analysis::getDate); - } - - @Override public Optional<Analysis> getAnalysis() { return Optional.ofNullable(analysis); } @@ -836,8 +760,7 @@ public class PostProjectAnalysisTaskTester { @Override public String toString() { return "ProjectAnalysis{" + - "organization=" + organization + - ", ceTask=" + ceTask + + "ceTask=" + ceTask + ", project=" + project + ", date=" + date.getTime() + ", analysisDate=" + date.getTime() + diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTesterTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTesterTest.java index 744ca9b5fad..949dcb63d3d 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTesterTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTesterTest.java @@ -39,7 +39,6 @@ public class PostProjectAnalysisTaskTesterTest { @Rule public ExpectedException expectedException = ExpectedException.none(); - private Organization organization = mock(Organization.class); private CeTask ceTask = mock(CeTask.class); private Project project = mock(Project.class); private long someDateAsLong = 846351351684351L; @@ -108,32 +107,29 @@ public class PostProjectAnalysisTaskTesterTest { @Test public void verify_getters_of_ProjectAnalysis_object_passed_to_PostProjectAnalysisTask() { - underTest.withOrganization(organization).withCeTask(ceTask).withProject(project).withQualityGate(qualityGate).withAnalysisUuid(analysisUuid).at(someDate); + underTest.withCeTask(ceTask).withProject(project).withQualityGate(qualityGate).withAnalysisUuid(analysisUuid).at(someDate); underTest.execute(); PostProjectAnalysisTask.ProjectAnalysis projectAnalysis = captorPostProjectAnalysisTask.projectAnalysis; assertThat(projectAnalysis).isNotNull(); - assertThat(projectAnalysis.getOrganization().get()).isSameAs(organization); assertThat(projectAnalysis.getCeTask()).isSameAs(ceTask); assertThat(projectAnalysis.getProject()).isSameAs(project); - assertThat(projectAnalysis.getDate()).isSameAs(someDate); assertThat(projectAnalysis.getQualityGate()).isSameAs(qualityGate); assertThat(projectAnalysis.getAnalysis().get().getAnalysisUuid()).isSameAs(analysisUuid); } @Test public void verify_toString_of_ProjectAnalysis_object_passed_to_PostProjectAnalysisTask() { - when(organization.toString()).thenReturn("Organization"); when(ceTask.toString()).thenReturn("CeTask"); when(project.toString()).thenReturn("Project"); when(qualityGate.toString()).thenReturn("QualityGate"); - underTest.withOrganization(organization).withCeTask(ceTask).withProject(project).withQualityGate(qualityGate).at(someDate); + underTest.withCeTask(ceTask).withProject(project).withQualityGate(qualityGate).at(someDate); underTest.execute(); - assertThat(captorPostProjectAnalysisTask.projectAnalysis.toString()) - .isEqualTo("ProjectAnalysis{organization=Organization, ceTask=CeTask, project=Project, date=846351351684351, analysisDate=846351351684351, qualityGate=QualityGate}"); + assertThat(captorPostProjectAnalysisTask.projectAnalysis) + .hasToString("ProjectAnalysis{ceTask=CeTask, project=Project, date=846351351684351, analysisDate=846351351684351, qualityGate=QualityGate}"); } @@ -157,7 +153,7 @@ public class PostProjectAnalysisTaskTesterTest { @Test public void getLogStatistics_returns_empty_if_no_log_statistic_added_by_tested_Task() { - underTest.withOrganization(organization).withCeTask(ceTask).withProject(project).withQualityGate(qualityGate).withAnalysisUuid(analysisUuid).at(someDate); + underTest.withCeTask(ceTask).withProject(project).withQualityGate(qualityGate).withAnalysisUuid(analysisUuid).at(someDate); underTest.execute(); @@ -178,7 +174,7 @@ public class PostProjectAnalysisTaskTesterTest { return null; }).when(projectAnalysisTask).finished(any(PostProjectAnalysisTask.Context.class)); PostProjectAnalysisTaskTester underTest = PostProjectAnalysisTaskTester.of(projectAnalysisTask); - underTest.withOrganization(organization).withCeTask(ceTask).withProject(project).withQualityGate(qualityGate).withAnalysisUuid(analysisUuid).at(someDate); + underTest.withCeTask(ceTask).withProject(project).withQualityGate(qualityGate).withAnalysisUuid(analysisUuid).at(someDate); underTest.execute(); |