From bd839a5cd75785456330f6c282a42ed2c3dc6725 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 28 May 2012 23:10:10 +0200 Subject: [PATCH] Extract beta api from review workflow --- .../org/sonar/core/review/package-info.java | 2 + .../review => workflow}/ImmutableReview.java | 105 +++++++----------- .../workflow/ReviewDatabaseStore.java | 6 +- .../{review => }/workflow/ReviewStore.java | 4 +- .../{review => }/workflow/WorkflowEngine.java | 24 ++-- .../{review => }/workflow/package-info.java | 2 +- .../workflow/SampleWorkflowBuilderTest.java | 37 ------ .../workflow/ReviewDatabaseStoreTest.java | 8 +- .../workflow/WorkflowEngineTest.java | 37 +++--- .../ReviewDatabaseStoreTest/store-result.xml | 0 .../ReviewDatabaseStoreTest/store.xml | 0 .../java/org/sonar/api/web/FilterColumn.java | 2 +- .../java/org/sonar/api/workflow}/Comment.java | 8 +- .../sonar/api/workflow}/MutableReview.java | 11 +- .../java/org/sonar/api/workflow}/Review.java | 38 ++++++- .../java/org/sonar/api/workflow/Workflow.java | 42 ++++--- .../sonar/api/workflow}/WorkflowContext.java | 12 +- .../condition/AdminRoleCondition.java | 10 +- .../api}/workflow/condition/Condition.java | 16 ++- .../api}/workflow/condition/Conditions.java | 2 +- .../HasProjectPropertyCondition.java | 10 +- .../condition/HasReviewPropertyCondition.java | 6 +- .../api}/workflow/condition/NotCondition.java | 15 ++- .../condition/ProjectPropertyCondition.java | 8 +- .../condition/ResolutionCondition.java | 16 ++- .../workflow/condition/StatusCondition.java | 16 ++- .../api/workflow/condition}/package-info.java | 2 +- .../workflow/function/CommentFunction.java | 15 ++- .../api}/workflow/function/Function.java | 22 ++-- .../api/workflow/function}/package-info.java | 2 +- .../workflow/internal}/DefaultComment.java | 15 +-- .../api/workflow/internal}/DefaultReview.java | 34 ++---- .../workflow/internal/DefaultWorkflow.java | 25 +++-- .../internal}/DefaultWorkflowContext.java | 8 +- .../api/workflow/internal}/package-info.java | 10 +- .../org/sonar/api/workflow}/package-info.java | 3 +- .../api}/workflow/screen/CommentScreen.java | 9 +- .../sonar/api}/workflow/screen/Screen.java | 6 +- .../api/workflow/screen/package-info.java | 23 ++++ .../condition/AdminRoleConditionTest.java | 6 +- .../workflow/condition/ConditionTest.java | 6 +- .../workflow/condition/ConditionsTest.java | 2 +- .../HasProjectPropertyConditionTest.java | 7 +- .../HasReviewPropertyConditionTest.java | 6 +- .../workflow/condition/NotConditionTest.java | 10 +- .../ProjectPropertyConditionTest.java | 6 +- .../condition/ResolutionConditionTest.java | 8 +- .../condition/StatusConditionTest.java | 8 +- .../function/CommentFunctionTest.java | 8 +- .../internal/DefaultWorkflowTest.java | 45 ++++---- .../workflow/screen/CommentScreenTest.java | 2 +- .../org/sonar/server/platform/Platform.java | 8 +- .../java/org/sonar/server/ui/JRubyFacade.java | 10 +- .../WEB-INF/app/models/api/review_context.rb | 2 +- .../webapp/WEB-INF/app/models/rule_failure.rb | 4 +- .../app/views/project_reviews/_view.html.erb | 2 +- 56 files changed, 428 insertions(+), 323 deletions(-) rename sonar-core/src/main/java/org/sonar/core/{review/workflow/review => workflow}/ImmutableReview.java (53%) rename sonar-core/src/main/java/org/sonar/core/{review => }/workflow/ReviewDatabaseStore.java (95%) rename sonar-core/src/main/java/org/sonar/core/{review => }/workflow/ReviewStore.java (91%) rename sonar-core/src/main/java/org/sonar/core/{review => }/workflow/WorkflowEngine.java (88%) rename sonar-core/src/main/java/org/sonar/core/{review => }/workflow/package-info.java (90%) delete mode 100644 sonar-core/src/test/java/org/sonar/core/review/workflow/SampleWorkflowBuilderTest.java rename sonar-core/src/test/java/org/sonar/core/{review => }/workflow/ReviewDatabaseStoreTest.java (90%) rename sonar-core/src/test/java/org/sonar/core/{review => }/workflow/WorkflowEngineTest.java (83%) rename sonar-core/src/test/resources/org/sonar/core/{review => }/workflow/ReviewDatabaseStoreTest/store-result.xml (100%) rename sonar-core/src/test/resources/org/sonar/core/{review => }/workflow/ReviewDatabaseStoreTest/store.xml (100%) rename {sonar-core/src/main/java/org/sonar/core/review/workflow/review => sonar-plugin-api/src/main/java/org/sonar/api/workflow}/Comment.java (90%) rename {sonar-core/src/main/java/org/sonar/core/review/workflow/review => sonar-plugin-api/src/main/java/org/sonar/api/workflow}/MutableReview.java (81%) rename {sonar-core/src/main/java/org/sonar/core/review/workflow/review => sonar-plugin-api/src/main/java/org/sonar/api/workflow}/Review.java (59%) rename sonar-core/src/main/java/org/sonar/core/review/workflow/SampleWorkflowBuilder.java => sonar-plugin-api/src/main/java/org/sonar/api/workflow/Workflow.java (50%) rename {sonar-core/src/main/java/org/sonar/core/review/workflow/review => sonar-plugin-api/src/main/java/org/sonar/api/workflow}/WorkflowContext.java (87%) rename {sonar-core/src/main/java/org/sonar/core/review => sonar-plugin-api/src/main/java/org/sonar/api}/workflow/condition/AdminRoleCondition.java (82%) rename {sonar-core/src/main/java/org/sonar/core/review => sonar-plugin-api/src/main/java/org/sonar/api}/workflow/condition/Condition.java (70%) rename {sonar-core/src/main/java/org/sonar/core/review => sonar-plugin-api/src/main/java/org/sonar/api}/workflow/condition/Conditions.java (97%) rename {sonar-core/src/main/java/org/sonar/core/review => sonar-plugin-api/src/main/java/org/sonar/api}/workflow/condition/HasProjectPropertyCondition.java (86%) rename {sonar-core/src/main/java/org/sonar/core/review => sonar-plugin-api/src/main/java/org/sonar/api}/workflow/condition/HasReviewPropertyCondition.java (90%) rename {sonar-core/src/main/java/org/sonar/core/review => sonar-plugin-api/src/main/java/org/sonar/api}/workflow/condition/NotCondition.java (79%) rename {sonar-core/src/main/java/org/sonar/core/review => sonar-plugin-api/src/main/java/org/sonar/api}/workflow/condition/ProjectPropertyCondition.java (91%) rename {sonar-core/src/main/java/org/sonar/core/review => sonar-plugin-api/src/main/java/org/sonar/api}/workflow/condition/ResolutionCondition.java (81%) rename {sonar-core/src/main/java/org/sonar/core/review => sonar-plugin-api/src/main/java/org/sonar/api}/workflow/condition/StatusCondition.java (81%) rename {sonar-core/src/main/java/org/sonar/core/review/workflow/review => sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition}/package-info.java (89%) rename {sonar-core/src/main/java/org/sonar/core/review => sonar-plugin-api/src/main/java/org/sonar/api}/workflow/function/CommentFunction.java (81%) rename {sonar-core/src/main/java/org/sonar/core/review => sonar-plugin-api/src/main/java/org/sonar/api}/workflow/function/Function.java (66%) rename {sonar-core/src/main/java/org/sonar/core/review/workflow/screen => sonar-plugin-api/src/main/java/org/sonar/api/workflow/function}/package-info.java (89%) rename {sonar-core/src/main/java/org/sonar/core/review/workflow/review => sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal}/DefaultComment.java (86%) rename {sonar-core/src/main/java/org/sonar/core/review/workflow/review => sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal}/DefaultReview.java (86%) rename sonar-core/src/main/java/org/sonar/core/review/workflow/Workflow.java => sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/DefaultWorkflow.java (87%) rename {sonar-core/src/main/java/org/sonar/core/review/workflow/review => sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal}/DefaultWorkflowContext.java (94%) rename {sonar-core/src/main/java/org/sonar/core/review/workflow/condition => sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal}/package-info.java (72%) rename {sonar-core/src/main/java/org/sonar/core/review/workflow/function => sonar-plugin-api/src/main/java/org/sonar/api/workflow}/package-info.java (89%) rename {sonar-core/src/main/java/org/sonar/core/review => sonar-plugin-api/src/main/java/org/sonar/api}/workflow/screen/CommentScreen.java (90%) rename {sonar-core/src/main/java/org/sonar/core/review => sonar-plugin-api/src/main/java/org/sonar/api}/workflow/screen/Screen.java (93%) create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/workflow/screen/package-info.java rename {sonar-core/src/test/java/org/sonar/core/review => sonar-plugin-api/src/test/java/org/sonar/api}/workflow/condition/AdminRoleConditionTest.java (89%) rename {sonar-core/src/test/java/org/sonar/core/review => sonar-plugin-api/src/test/java/org/sonar/api}/workflow/condition/ConditionTest.java (90%) rename {sonar-core/src/test/java/org/sonar/core/review => sonar-plugin-api/src/test/java/org/sonar/api}/workflow/condition/ConditionsTest.java (98%) rename {sonar-core/src/test/java/org/sonar/core/review => sonar-plugin-api/src/test/java/org/sonar/api}/workflow/condition/HasProjectPropertyConditionTest.java (92%) rename {sonar-core/src/test/java/org/sonar/core/review => sonar-plugin-api/src/test/java/org/sonar/api}/workflow/condition/HasReviewPropertyConditionTest.java (91%) rename {sonar-core/src/test/java/org/sonar/core/review => sonar-plugin-api/src/test/java/org/sonar/api}/workflow/condition/NotConditionTest.java (84%) rename {sonar-core/src/test/java/org/sonar/core/review => sonar-plugin-api/src/test/java/org/sonar/api}/workflow/condition/ProjectPropertyConditionTest.java (88%) rename {sonar-core/src/test/java/org/sonar/core/review => sonar-plugin-api/src/test/java/org/sonar/api}/workflow/condition/ResolutionConditionTest.java (89%) rename {sonar-core/src/test/java/org/sonar/core/review => sonar-plugin-api/src/test/java/org/sonar/api}/workflow/condition/StatusConditionTest.java (89%) rename {sonar-core/src/test/java/org/sonar/core/review => sonar-plugin-api/src/test/java/org/sonar/api}/workflow/function/CommentFunctionTest.java (88%) rename sonar-core/src/test/java/org/sonar/core/review/workflow/WorkflowTest.java => sonar-plugin-api/src/test/java/org/sonar/api/workflow/internal/DefaultWorkflowTest.java (80%) rename {sonar-core/src/test/java/org/sonar/core/review => sonar-plugin-api/src/test/java/org/sonar/api}/workflow/screen/CommentScreenTest.java (96%) diff --git a/sonar-core/src/main/java/org/sonar/core/review/package-info.java b/sonar-core/src/main/java/org/sonar/core/review/package-info.java index 8e8e350ae15..b9180bc8ce9 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/package-info.java +++ b/sonar-core/src/main/java/org/sonar/core/review/package-info.java @@ -17,5 +17,7 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ +@ParametersAreNonnullByDefault package org.sonar.core.review; +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/ImmutableReview.java b/sonar-core/src/main/java/org/sonar/core/workflow/ImmutableReview.java similarity index 53% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/review/ImmutableReview.java rename to sonar-core/src/main/java/org/sonar/core/workflow/ImmutableReview.java index 35c8f01a470..2194b535e7e 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/ImmutableReview.java +++ b/sonar-core/src/main/java/org/sonar/core/workflow/ImmutableReview.java @@ -17,126 +17,97 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.review; +package org.sonar.core.workflow; + +import com.google.common.collect.ImmutableMap; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.internal.DefaultReview; import java.util.Map; -public class ImmutableReview implements Review { - private Long violationId; - private Long reviewId; - private String ruleRepositoryKey; - private String ruleKey; - private String ruleName; - private Long line; - private boolean switchedOff = false; - private boolean manual = false; - private String message; - private String status; - private String resolution; - private String severity; - private Map properties; +public final class ImmutableReview implements Review { + private final Long violationId; + private final Long reviewId; + private final String ruleRepositoryKey; + private final String ruleKey; + private final String ruleName; + private final Long line; + private final boolean switchedOff; + private final boolean manual; + private final String message; + private final String status; + private final String resolution; + private final String severity; + private final Map properties; + + /** + * Warning : implementation is still mutable. + */ + public ImmutableReview(DefaultReview review) { + this.line = review.getLine(); + this.manual = review.isManual(); + this.message = review.getMessage(); + this.properties = ImmutableMap.copyOf(review.getProperties()); + this.resolution = review.getResolution(); + this.reviewId = review.getReviewId(); + this.ruleKey = review.getRuleKey(); + this.ruleRepositoryKey = review.getRuleRepositoryKey(); + this.ruleName = review.getRuleName(); + this.severity = review.getSeverity(); + this.status = review.getStatus(); + this.switchedOff = review.isSwitchedOff(); + this.violationId = review.getViolationId(); + } public Long getViolationId() { return violationId; } - void setViolationId(Long violationId) { - this.violationId = violationId; - } - public Long getReviewId() { return reviewId; } - void setReviewId(Long reviewId) { - this.reviewId = reviewId; - } - public String getRuleName() { return ruleName; } - void setRuleName(String s) { - this.ruleName = s; - } - public String getRuleRepositoryKey() { return ruleRepositoryKey; } - void setRuleRepositoryKey(String ruleRepositoryKey) { - this.ruleRepositoryKey = ruleRepositoryKey; - } - public String getRuleKey() { return ruleKey; } - void setRuleKey(String ruleKey) { - this.ruleKey = ruleKey; - } - public Long getLine() { return line; } - void setLine(Long line) { - this.line = line; - } - public boolean isSwitchedOff() { return switchedOff; } - void setSwitchedOff(boolean switchedOff) { - this.switchedOff = switchedOff; - } - public boolean isManual() { return manual; } - void setManual(boolean manual) { - this.manual = manual; - } - public String getMessage() { return message; } - void setMessage(String message) { - this.message = message; - } - public String getStatus() { return status; } - void setStatus(String status) { - this.status = status; - } - public String getResolution() { return resolution; } - void setResolution(String resolution) { - this.resolution = resolution; - } - public String getSeverity() { return severity; } - void setSeverity(String severity) { - this.severity = severity; - } - public Map getProperties() { return properties; } - - void setProperties(Map properties) { - this.properties = properties; - } } diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/ReviewDatabaseStore.java b/sonar-core/src/main/java/org/sonar/core/workflow/ReviewDatabaseStore.java similarity index 95% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/ReviewDatabaseStore.java rename to sonar-core/src/main/java/org/sonar/core/workflow/ReviewDatabaseStore.java index 9dd425e38bc..81c6d0b3a71 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/ReviewDatabaseStore.java +++ b/sonar-core/src/main/java/org/sonar/core/workflow/ReviewDatabaseStore.java @@ -17,7 +17,7 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow; +package org.sonar.core.workflow; import com.google.common.annotations.VisibleForTesting; import org.apache.ibatis.session.SqlSession; @@ -33,8 +33,8 @@ import org.sonar.core.review.ReviewCommentDto; import org.sonar.core.review.ReviewCommentMapper; import org.sonar.core.review.ReviewDto; import org.sonar.core.review.ReviewMapper; -import org.sonar.core.review.workflow.review.Comment; -import org.sonar.core.review.workflow.review.DefaultReview; +import org.sonar.api.workflow.Comment; +import org.sonar.api.workflow.internal.DefaultReview; import java.util.Date; import java.util.List; diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/ReviewStore.java b/sonar-core/src/main/java/org/sonar/core/workflow/ReviewStore.java similarity index 91% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/ReviewStore.java rename to sonar-core/src/main/java/org/sonar/core/workflow/ReviewStore.java index 36540973903..f5a67470f68 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/ReviewStore.java +++ b/sonar-core/src/main/java/org/sonar/core/workflow/ReviewStore.java @@ -17,10 +17,10 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow; +package org.sonar.core.workflow; import org.sonar.api.config.Settings; -import org.sonar.core.review.workflow.review.DefaultReview; +import org.sonar.api.workflow.internal.DefaultReview; import java.util.List; public interface ReviewStore { diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/WorkflowEngine.java b/sonar-core/src/main/java/org/sonar/core/workflow/WorkflowEngine.java similarity index 88% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/WorkflowEngine.java rename to sonar-core/src/main/java/org/sonar/core/workflow/WorkflowEngine.java index a73d42cadf1..450c949756e 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/WorkflowEngine.java +++ b/sonar-core/src/main/java/org/sonar/core/workflow/WorkflowEngine.java @@ -17,7 +17,7 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow; +package org.sonar.core.workflow; import com.google.common.base.Preconditions; import com.google.common.base.Strings; @@ -27,26 +27,26 @@ import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import org.sonar.api.ServerComponent; import org.sonar.api.config.Settings; -import org.sonar.core.review.workflow.condition.Condition; -import org.sonar.core.review.workflow.function.Function; -import org.sonar.core.review.workflow.review.DefaultReview; -import org.sonar.core.review.workflow.review.DefaultWorkflowContext; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.review.WorkflowContext; -import org.sonar.core.review.workflow.screen.Screen; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; +import org.sonar.api.workflow.condition.Condition; +import org.sonar.api.workflow.function.Function; +import org.sonar.api.workflow.internal.DefaultReview; +import org.sonar.api.workflow.internal.DefaultWorkflow; +import org.sonar.api.workflow.internal.DefaultWorkflowContext; +import org.sonar.api.workflow.screen.Screen; import javax.annotation.Nullable; - import java.util.List; import java.util.Map; public class WorkflowEngine implements ServerComponent { - private final Workflow workflow; + private final DefaultWorkflow workflow; private final ReviewStore store; private final Settings settings; - public WorkflowEngine(Workflow workflow, ReviewStore store, Settings settings) { + public WorkflowEngine(DefaultWorkflow workflow, ReviewStore store, Settings settings) { this.workflow = workflow; this.store = store; this.settings = settings; @@ -104,7 +104,7 @@ public class WorkflowEngine implements ServerComponent { Map immutableParameters = ImmutableMap.copyOf(parameters); // TODO execute functions are change state before functions that consume state (like "create-jira-issue") - Review initialReview = review.cloneImmutable(); + Review initialReview = new ImmutableReview(review); for (Function function : workflow.getFunctions(commandKey)) { function.doExecute(review, initialReview, context, immutableParameters); } diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/package-info.java b/sonar-core/src/main/java/org/sonar/core/workflow/package-info.java similarity index 90% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/package-info.java rename to sonar-core/src/main/java/org/sonar/core/workflow/package-info.java index 27652dae71c..c3d167a10b6 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/package-info.java +++ b/sonar-core/src/main/java/org/sonar/core/workflow/package-info.java @@ -18,6 +18,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ @ParametersAreNonnullByDefault -package org.sonar.core.review.workflow; +package org.sonar.core.workflow; import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/SampleWorkflowBuilderTest.java b/sonar-core/src/test/java/org/sonar/core/review/workflow/SampleWorkflowBuilderTest.java deleted file mode 100644 index 285396cbfd7..00000000000 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/SampleWorkflowBuilderTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.core.review.workflow; - -import org.junit.Test; - -import static org.fest.assertions.Assertions.assertThat; - -public class SampleWorkflowBuilderTest { - @Test - public void completeWorkflowAtStartup() { - Workflow workflow = new Workflow(); - - new SampleWorkflowBuilder(workflow).start(); - - assertThat(workflow.getCommands()).containsOnly("comment"); - assertThat(workflow.getScreen("comment")).isNotNull(); - assertThat(workflow.getFunctions("comment")).hasSize(1); - } -} diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/ReviewDatabaseStoreTest.java b/sonar-core/src/test/java/org/sonar/core/workflow/ReviewDatabaseStoreTest.java similarity index 90% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/ReviewDatabaseStoreTest.java rename to sonar-core/src/test/java/org/sonar/core/workflow/ReviewDatabaseStoreTest.java index 0dbfa6a6d3b..8294d3ce7bf 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/ReviewDatabaseStoreTest.java +++ b/sonar-core/src/test/java/org/sonar/core/workflow/ReviewDatabaseStoreTest.java @@ -17,13 +17,15 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow; +package org.sonar.core.workflow; import org.junit.Test; import org.sonar.api.utils.DateUtils; import org.sonar.core.persistence.DaoTestCase; -import org.sonar.core.review.workflow.review.Comment; -import org.sonar.core.review.workflow.review.DefaultReview; +import org.sonar.api.workflow.Comment; +import org.sonar.api.workflow.internal.DefaultReview; +import org.sonar.core.workflow.ReviewDatabaseStore; + import java.util.Date; public class ReviewDatabaseStoreTest extends DaoTestCase { diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/WorkflowEngineTest.java b/sonar-core/src/test/java/org/sonar/core/workflow/WorkflowEngineTest.java similarity index 83% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/WorkflowEngineTest.java rename to sonar-core/src/test/java/org/sonar/core/workflow/WorkflowEngineTest.java index 29f86a9b1be..b38a4a8793e 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/WorkflowEngineTest.java +++ b/sonar-core/src/test/java/org/sonar/core/workflow/WorkflowEngineTest.java @@ -17,7 +17,7 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow; +package org.sonar.core.workflow; import com.google.common.collect.ListMultimap; import com.google.common.collect.Maps; @@ -25,12 +25,19 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.config.Settings; -import org.sonar.core.review.workflow.condition.Condition; -import org.sonar.core.review.workflow.condition.HasProjectPropertyCondition; -import org.sonar.core.review.workflow.function.Function; -import org.sonar.core.review.workflow.review.*; -import org.sonar.core.review.workflow.screen.CommentScreen; -import org.sonar.core.review.workflow.screen.Screen; +import org.sonar.api.workflow.internal.DefaultWorkflow; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; +import org.sonar.api.workflow.condition.Condition; +import org.sonar.api.workflow.condition.HasProjectPropertyCondition; +import org.sonar.api.workflow.function.Function; +import org.sonar.api.workflow.internal.DefaultReview; +import org.sonar.api.workflow.internal.DefaultWorkflowContext; +import org.sonar.api.workflow.screen.CommentScreen; +import org.sonar.api.workflow.screen.Screen; +import org.sonar.core.workflow.ImmutableReview; +import org.sonar.core.workflow.ReviewStore; +import org.sonar.core.workflow.WorkflowEngine; import java.util.List; import java.util.Map; @@ -47,14 +54,14 @@ public class WorkflowEngineTest { @Test public void listAvailableScreensForReview_empty() { - WorkflowEngine engine = new WorkflowEngine(new Workflow(), mock(ReviewStore.class), new Settings()); + WorkflowEngine engine = new WorkflowEngine(new DefaultWorkflow(), mock(ReviewStore.class), new Settings()); List screens = engine.listAvailableScreens(new DefaultReview(), new DefaultWorkflowContext(), true); assertThat(screens).isEmpty(); } @Test public void listAvailableScreensForReview() { - Workflow workflow = new Workflow(); + DefaultWorkflow workflow = new DefaultWorkflow(); workflow.addCommand("command-without-screen"); workflow.addCommand("resolve"); CommentScreen screen = new CommentScreen(); @@ -67,7 +74,7 @@ public class WorkflowEngineTest { @Test public void listAvailableScreensForReview_verify_conditions() { - Workflow workflow = new Workflow(); + DefaultWorkflow workflow = new DefaultWorkflow(); workflow.addCommand("resolve"); Condition condition = mock(Condition.class); when(condition.doVerify(any(Review.class), any(WorkflowContext.class))).thenReturn(false); @@ -84,7 +91,7 @@ public class WorkflowEngineTest { @Test public void listAvailableScreensForReviews_empty() { - WorkflowEngine engine = new WorkflowEngine(new Workflow(), mock(ReviewStore.class), new Settings()); + WorkflowEngine engine = new WorkflowEngine(new DefaultWorkflow(), mock(ReviewStore.class), new Settings()); ListMultimap screens = engine.listAvailableScreens( new DefaultReview[]{new DefaultReview().setViolationId(1000L), new DefaultReview().setViolationId(2000L)}, new DefaultWorkflowContext(), true); @@ -93,7 +100,7 @@ public class WorkflowEngineTest { @Test public void listAvailableScreensForReviews() { - Workflow workflow = new Workflow(); + DefaultWorkflow workflow = new DefaultWorkflow(); workflow.addCommand("command-without-screen"); workflow.addCommand("resolve"); CommentScreen screen = new CommentScreen(); @@ -109,7 +116,7 @@ public class WorkflowEngineTest { @Test public void listAvailableScreensForReviews_load_project_properties() { - Workflow workflow = new Workflow(); + DefaultWorkflow workflow = new DefaultWorkflow(); workflow.addCommand("resolve"); workflow.addCondition("resolve", new HasProjectPropertyCondition("foo")); @@ -126,7 +133,7 @@ public class WorkflowEngineTest { @Test public void execute_conditions_pass() { - Workflow workflow = new Workflow(); + DefaultWorkflow workflow = new DefaultWorkflow(); workflow.addCommand("resolve"); workflow.addCondition("resolve", new HasProjectPropertyCondition("foo")); Function function = mock(Function.class); @@ -152,7 +159,7 @@ public class WorkflowEngineTest { thrown.expect(IllegalStateException.class); thrown.expectMessage("Condition is not respected: Property foo must be set"); - Workflow workflow = new Workflow(); + DefaultWorkflow workflow = new DefaultWorkflow(); workflow.addCommand("resolve"); workflow.addCondition("resolve", new HasProjectPropertyCondition("foo")); Function function = mock(Function.class); diff --git a/sonar-core/src/test/resources/org/sonar/core/review/workflow/ReviewDatabaseStoreTest/store-result.xml b/sonar-core/src/test/resources/org/sonar/core/workflow/ReviewDatabaseStoreTest/store-result.xml similarity index 100% rename from sonar-core/src/test/resources/org/sonar/core/review/workflow/ReviewDatabaseStoreTest/store-result.xml rename to sonar-core/src/test/resources/org/sonar/core/workflow/ReviewDatabaseStoreTest/store-result.xml diff --git a/sonar-core/src/test/resources/org/sonar/core/review/workflow/ReviewDatabaseStoreTest/store.xml b/sonar-core/src/test/resources/org/sonar/core/workflow/ReviewDatabaseStoreTest/store.xml similarity index 100% rename from sonar-core/src/test/resources/org/sonar/core/review/workflow/ReviewDatabaseStoreTest/store.xml rename to sonar-core/src/test/resources/org/sonar/core/workflow/ReviewDatabaseStoreTest/store.xml diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/FilterColumn.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/FilterColumn.java index d5e8e323cd6..fb8516ec9f7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/FilterColumn.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/FilterColumn.java @@ -91,7 +91,7 @@ public final class FilterColumn { } /** - * A column can be based on the varation of a value rather than on the value itself. + * A column can be based on the variation of a value rather than on the value itself. * * @return true when the variation is used rather than the value */ diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/Comment.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/Comment.java similarity index 90% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/review/Comment.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/Comment.java index c648471d8dc..c478ad6f355 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/Comment.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/Comment.java @@ -17,8 +17,14 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.review; +package org.sonar.api.workflow; +import com.google.common.annotations.Beta; + +/** + * @since 3.1 + */ +@Beta public interface Comment { String getMarkdownText(); diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/MutableReview.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/MutableReview.java similarity index 81% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/review/MutableReview.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/MutableReview.java index 286254dcdb8..5d1e3316029 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/MutableReview.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/MutableReview.java @@ -17,11 +17,20 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.review; +package org.sonar.api.workflow; + +import com.google.common.annotations.Beta; import javax.annotation.Nullable; import java.util.List; +/** + * Review that can be changed by functions. It does not support (yet) changes + * on creation date, author, severity, existing comments or switched-off attribute. + * + * @since 3.1 + */ +@Beta public interface MutableReview extends Review { MutableReview setStatus(String s); diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/Review.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/Review.java similarity index 59% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/review/Review.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/Review.java index 7cca22da27b..9ff51f00b4c 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/Review.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/Review.java @@ -17,33 +17,67 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.review; +package org.sonar.api.workflow; + +import com.google.common.annotations.Beta; import java.util.Map; +/** + * @since 3.1 + */ +@Beta public interface Review { + /** + * This method will probably be removed in order to decrease + * coupling with database. + * + * @return not-null review id (primary key of the table REVIEWS). + */ Long getReviewId(); + /** + * @return not-null rule repository, for example "checkstyle" + */ String getRuleRepositoryKey(); + /** + * @return not-null rule key + */ String getRuleKey(); + /** + * @return not-null rule name, in English. + */ String getRuleName(); boolean isSwitchedOff(); String getMessage(); - Map getProperties(); + /** + * @return not-null properties + */ + Map getProperties(); String getStatus(); String getResolution(); + /** + * @return not-null severity, from INFO to BLOCKER + */ String getSeverity(); + /** + * @return optional line, starting from 1 + */ Long getLine(); + /** + * @return true if the violation has been created by an automated rule engine, + * false if created by an end-user. + */ boolean isManual(); } diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/SampleWorkflowBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/Workflow.java similarity index 50% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/SampleWorkflowBuilder.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/Workflow.java index a6a89ccd2c6..0e3d4e78a7d 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/SampleWorkflowBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/Workflow.java @@ -17,26 +17,38 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow; +package org.sonar.api.workflow; -import org.sonar.api.ServerExtension; -import org.sonar.core.review.workflow.function.CommentFunction; -import org.sonar.core.review.workflow.screen.CommentScreen; +import com.google.common.annotations.Beta; +import org.sonar.api.ServerComponent; +import org.sonar.api.workflow.condition.Condition; +import org.sonar.api.workflow.function.Function; +import org.sonar.api.workflow.screen.Screen; + +import java.util.List; +import java.util.Set; /** - * Sample of workflow customization. Not used. + * Experimental component to customize the actions that can be + * executed on reviews. + * + * @since 3.1 */ -public class SampleWorkflowBuilder implements ServerExtension { +@Beta +public interface Workflow extends ServerComponent { + Workflow addCommand(String key); + + Set getCommands(); + + List getConditions(String commandKey); + + Workflow addCondition(String commandKey, Condition condition); + + List getFunctions(String commandKey); - private final Workflow workflow; + Workflow addFunction(String commandKey, Function function); - public SampleWorkflowBuilder(Workflow workflow) { - this.workflow = workflow; - } + Screen getScreen(String commandKey); - public void start() { - workflow.addCommand("comment"); - workflow.setScreen("comment", new CommentScreen()); - workflow.addFunction("comment", new CommentFunction()); - } + Workflow setScreen(String commandKey, Screen screen); } diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/WorkflowContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/WorkflowContext.java similarity index 87% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/review/WorkflowContext.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/WorkflowContext.java index 7c0f2faa17c..693e43a70e2 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/WorkflowContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/WorkflowContext.java @@ -17,11 +17,20 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.review; +package org.sonar.api.workflow; +import com.google.common.annotations.Beta; import org.sonar.api.config.Settings; +/** + * @since 3.1 + */ +@Beta public interface WorkflowContext { + + /** + * TODO : to be replaced by getProjectKey() + */ Long getProjectId(); Long getUserId(); @@ -35,4 +44,5 @@ public interface WorkflowContext { boolean isAdmin(); Settings getProjectSettings(); + } diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/AdminRoleCondition.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/AdminRoleCondition.java similarity index 82% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/condition/AdminRoleCondition.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/AdminRoleCondition.java index 6868361fde2..ee0595c8c0e 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/AdminRoleCondition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/AdminRoleCondition.java @@ -17,11 +17,13 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import com.google.common.annotations.Beta; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.review.WorkflowContext; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; + +import javax.annotation.Nullable; /** * Checks that user has admin rights on project. @@ -36,7 +38,7 @@ public final class AdminRoleCondition extends Condition { } @Override - public boolean doVerify(Review review, WorkflowContext context) { + public boolean doVerify(@Nullable Review review, WorkflowContext context) { return context.isAdmin(); } } diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/Condition.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/Condition.java similarity index 70% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/condition/Condition.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/Condition.java index f5386879bf4..985f51b03e6 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/Condition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/Condition.java @@ -17,15 +17,18 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import com.google.common.annotations.Beta; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.review.WorkflowContext; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; import javax.annotation.Nullable; /** + * Conditions control who can perform a command (i.e. who can see the screen + * associated to the command). + * * @since 3.1 */ @Beta @@ -37,12 +40,17 @@ public abstract class Condition { this.onContext = onContext; } + /** + * @return true if the condition relates to a review, false if it relates to the resource + * context (selected file, end-user, ...) + */ public final boolean isOnContext() { return onContext; } /** - * @param review the review on "review conditions" like StatusCondition, null on "context conditions" like AdminRoleCondition or ProjectPropertyCondition + * @param review the review on "review conditions" like StatusCondition, null on "context conditions" + * like AdminRoleCondition or ProjectPropertyCondition * @param context * @return is the condition verified ? */ diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/Conditions.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/Conditions.java similarity index 97% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/condition/Conditions.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/Conditions.java index 2e3c1a1a564..ac8985125b4 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/Conditions.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/Conditions.java @@ -17,7 +17,7 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import com.google.common.annotations.Beta; diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/HasProjectPropertyCondition.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/HasProjectPropertyCondition.java similarity index 86% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/condition/HasProjectPropertyCondition.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/HasProjectPropertyCondition.java index 046aedb799b..df9ce0dac62 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/HasProjectPropertyCondition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/HasProjectPropertyCondition.java @@ -17,12 +17,14 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import com.google.common.annotations.Beta; import org.sonar.api.config.Settings; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.review.WorkflowContext; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; + +import javax.annotation.Nullable; /** * Checks that a project property is set, whatever its value. @@ -37,7 +39,7 @@ public final class HasProjectPropertyCondition extends ProjectPropertyCondition } @Override - public boolean doVerify(Review review, WorkflowContext context) { + public boolean doVerify(@Nullable Review review, WorkflowContext context) { Settings settings = context.getProjectSettings(); return settings.hasKey(getPropertyKey()) || settings.getDefaultValue(getPropertyKey()) != null; } diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/HasReviewPropertyCondition.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/HasReviewPropertyCondition.java similarity index 90% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/condition/HasReviewPropertyCondition.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/HasReviewPropertyCondition.java index a9922a98b9d..09afc8cc4d8 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/HasReviewPropertyCondition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/HasReviewPropertyCondition.java @@ -17,13 +17,13 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.base.Strings; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.review.WorkflowContext; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; import javax.annotation.Nullable; diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/NotCondition.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/NotCondition.java similarity index 79% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/condition/NotCondition.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/NotCondition.java index bdaba1bdc89..3eabc3f575b 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/NotCondition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/NotCondition.java @@ -17,12 +17,19 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; +import com.google.common.annotations.Beta; import com.google.common.annotations.VisibleForTesting; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.review.WorkflowContext; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; +import javax.annotation.Nullable; + +/** + * @since 3.1 + */ +@Beta public final class NotCondition extends Condition { private Condition condition; @@ -33,7 +40,7 @@ public final class NotCondition extends Condition { } @Override - public boolean doVerify(Review review, WorkflowContext context) { + public boolean doVerify(@Nullable Review review, WorkflowContext context) { return !condition.doVerify(review, context); } diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/ProjectPropertyCondition.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/ProjectPropertyCondition.java similarity index 91% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/condition/ProjectPropertyCondition.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/ProjectPropertyCondition.java index ae0e148b26d..9c19004dc8b 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/ProjectPropertyCondition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/ProjectPropertyCondition.java @@ -17,12 +17,16 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; +import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.base.Strings; - +/** + * @since 3.1 + */ +@Beta public abstract class ProjectPropertyCondition extends Condition { private final String propertyKey; diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/ResolutionCondition.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/ResolutionCondition.java similarity index 81% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/condition/ResolutionCondition.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/ResolutionCondition.java index b7750faa027..080df298700 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/ResolutionCondition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/ResolutionCondition.java @@ -17,18 +17,24 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; +import com.google.common.annotations.Beta; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.review.WorkflowContext; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; +import javax.annotation.Nullable; import java.util.Arrays; import java.util.Set; +/** + * @since 3.1 + */ +@Beta public final class ResolutionCondition extends Condition { private final Set resolutions; @@ -44,8 +50,8 @@ public final class ResolutionCondition extends Condition { } @Override - public boolean doVerify(Review review, WorkflowContext context) { - return resolutions.contains(review.getResolution()); + public boolean doVerify(@Nullable Review review, WorkflowContext context) { + return review != null && resolutions.contains(review.getResolution()); } @VisibleForTesting diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/StatusCondition.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/StatusCondition.java similarity index 81% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/condition/StatusCondition.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/StatusCondition.java index 5b443ee9f38..f27709fec3a 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/StatusCondition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/StatusCondition.java @@ -17,18 +17,24 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; +import com.google.common.annotations.Beta; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.review.WorkflowContext; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; +import javax.annotation.Nullable; import java.util.Arrays; import java.util.Set; +/** + * @since 3.1 + */ +@Beta public final class StatusCondition extends Condition { private final Set statuses; @@ -44,8 +50,8 @@ public final class StatusCondition extends Condition { } @Override - public boolean doVerify(Review review, WorkflowContext context) { - return statuses.contains(review.getStatus()); + public boolean doVerify(@Nullable Review review, WorkflowContext context) { + return review != null && statuses.contains(review.getStatus()); } @VisibleForTesting diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/package-info.java similarity index 89% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/review/package-info.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/package-info.java index 0e49d65ce22..f8b3ec06f20 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/package-info.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/condition/package-info.java @@ -18,6 +18,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ @ParametersAreNonnullByDefault -package org.sonar.core.review.workflow.review; +package org.sonar.api.workflow.condition; import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/function/CommentFunction.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/function/CommentFunction.java similarity index 81% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/function/CommentFunction.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/function/CommentFunction.java index f9131b71f8c..c75e358c8c8 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/function/CommentFunction.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/function/CommentFunction.java @@ -17,15 +17,20 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.function; +package org.sonar.api.workflow.function; -import org.sonar.core.review.workflow.review.Comment; -import org.sonar.core.review.workflow.review.MutableReview; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.review.WorkflowContext; +import com.google.common.annotations.Beta; +import org.sonar.api.workflow.Comment; +import org.sonar.api.workflow.MutableReview; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; import java.util.Map; +/** + * @since 3.1 + */ +@Beta public final class CommentFunction extends Function { @Override diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/function/Function.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/function/Function.java similarity index 66% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/function/Function.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/function/Function.java index 1f941d4f1dc..11ad2362e3a 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/function/Function.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/function/Function.java @@ -17,16 +17,24 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.function; +package org.sonar.api.workflow.function; import com.google.common.annotations.Beta; -import org.sonar.core.review.workflow.review.MutableReview; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.review.WorkflowContext; +import org.sonar.api.workflow.MutableReview; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; import java.util.Map; /** + * Functions perform actions when the command is executed, e.g.: + * + *
    + *
  • Assign the issue to a particular user (not yet implemented)
  • + *
  • Add a comment
  • + *
  • Set a review property
  • + *
+ * * @since 3.1 */ @Beta @@ -35,10 +43,10 @@ public abstract class Function { /** * This method is executed when all the conditions pass. * - * @param review the review that can be changed + * @param review the review that can be changed * @param initialReview the read-only review as stated before execution of functions - * @param context information about the user who executed the command and about project - * @param parameters the command parameters sent by end user, generally from forms displayed in screens + * @param context information about the user who executed the command and about project + * @param parameters the command parameters sent by end user, generally from forms displayed in screens */ public abstract void doExecute(MutableReview review, Review initialReview, WorkflowContext context, Map parameters); diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/screen/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/function/package-info.java similarity index 89% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/screen/package-info.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/function/package-info.java index 25a1028fd3c..a6ac723b57d 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/screen/package-info.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/function/package-info.java @@ -18,6 +18,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ @ParametersAreNonnullByDefault -package org.sonar.core.review.workflow.screen; +package org.sonar.api.workflow.function; import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultComment.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/DefaultComment.java similarity index 86% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultComment.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/DefaultComment.java index 47026442e9a..1887b202f46 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultComment.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/DefaultComment.java @@ -17,12 +17,18 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.review; +package org.sonar.api.workflow.internal; +import com.google.common.annotations.Beta; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; +import org.sonar.api.workflow.Comment; -public final class DefaultComment implements Comment, Cloneable { +/** + * @since 3.1 + */ +@Beta +public final class DefaultComment implements Comment { private String markdownText; private Long userId; @@ -51,9 +57,4 @@ public final class DefaultComment implements Comment, Cloneable { public String toString() { return new ReflectionToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).toString(); } - - @Override - public Comment clone() { - return new DefaultComment().setMarkdownText(markdownText).setUserId(userId); - } } diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultReview.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/DefaultReview.java similarity index 86% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultReview.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/DefaultReview.java index 68989f0921e..019463e8828 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultReview.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/DefaultReview.java @@ -17,15 +17,17 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.review; +package org.sonar.api.workflow.internal; +import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.base.Strings; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; +import org.sonar.api.workflow.Comment; +import org.sonar.api.workflow.MutableReview; import org.sonar.api.utils.KeyValueFormat; import javax.annotation.Nullable; @@ -33,6 +35,10 @@ import java.util.Collections; import java.util.List; import java.util.Map; +/** + * @since 3.1 + */ +@Beta public final class DefaultReview implements MutableReview { private Long violationId; @@ -206,26 +212,4 @@ public final class DefaultReview implements MutableReview { public String toString() { return new ReflectionToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).toString(); } - - /** - * Note : implementation is still mutable. - */ - public ImmutableReview cloneImmutable() { - ImmutableReview clone = new ImmutableReview(); - clone.setLine(line); - clone.setManual(manual); - clone.setMessage(message); - clone.setProperties(ImmutableMap.copyOf(getProperties())); - clone.setResolution(resolution); - clone.setReviewId(reviewId); - clone.setRuleKey(ruleKey); - clone.setRuleRepositoryKey(ruleRepositoryKey); - clone.setRuleName(ruleName); - clone.setSeverity(severity); - clone.setStatus(status); - clone.setSwitchedOff(switchedOff); - clone.setViolationId(violationId); - clone.setProperties(ImmutableMap.copyOf(getProperties())); - return clone; - } -} +} \ No newline at end of file diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/Workflow.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/DefaultWorkflow.java similarity index 87% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/Workflow.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/DefaultWorkflow.java index 3a4004e5b40..e6a0c87abd3 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/Workflow.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/DefaultWorkflow.java @@ -17,22 +17,27 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow; +package org.sonar.api.workflow.internal; +import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.*; -import org.sonar.api.ServerComponent; -import org.sonar.core.review.workflow.condition.Condition; -import org.sonar.core.review.workflow.condition.ProjectPropertyCondition; -import org.sonar.core.review.workflow.function.Function; -import org.sonar.core.review.workflow.screen.Screen; +import org.sonar.api.workflow.Workflow; +import org.sonar.api.workflow.condition.Condition; +import org.sonar.api.workflow.condition.ProjectPropertyCondition; +import org.sonar.api.workflow.function.Function; +import org.sonar.api.workflow.screen.Screen; import java.util.List; import java.util.Map; import java.util.Set; -public class Workflow implements ServerComponent { +/** + * @since 3.1 + */ +@Beta +public final class DefaultWorkflow implements Workflow { private Set commands = Sets.newLinkedHashSet(); private ListMultimap conditionsByCommand = ArrayListMultimap.create(); @@ -40,7 +45,7 @@ public class Workflow implements ServerComponent { private Map screensByCommand = Maps.newLinkedHashMap(); /** - * Keys of all the properties that are required by conditions (see {@link org.sonar.core.review.workflow.condition.ProjectPropertyCondition} + * Keys of all the properties that are required by conditions (see {@link org.sonar.api.workflow.condition.ProjectPropertyCondition} */ private List projectPropertyKeys = Lists.newArrayList(); @@ -69,7 +74,7 @@ public class Workflow implements ServerComponent { return commands.contains(key); } - List getProjectPropertyKeys() { + public List getProjectPropertyKeys() { return projectPropertyKeys; } @@ -127,7 +132,7 @@ public class Workflow implements ServerComponent { return this; } - Map getScreensByCommand() { + public Map getScreensByCommand() { return screensByCommand; } } diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultWorkflowContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/DefaultWorkflowContext.java similarity index 94% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultWorkflowContext.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/DefaultWorkflowContext.java index e8a1e3ec2e8..3101d431e29 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultWorkflowContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/DefaultWorkflowContext.java @@ -17,12 +17,18 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.review; +package org.sonar.api.workflow.internal; +import com.google.common.annotations.Beta; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.sonar.api.config.Settings; +import org.sonar.api.workflow.WorkflowContext; +/** + * @since 3.1 + */ +@Beta public final class DefaultWorkflowContext implements WorkflowContext { private Long userId; diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/package-info.java similarity index 72% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/condition/package-info.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/package-info.java index 06cd5142ac8..4ac8f86d8aa 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/condition/package-info.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/internal/package-info.java @@ -17,7 +17,15 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ + +/** + This package is not considered as API and future versions can break backward-compatibility. +

+ It provides some classes that can be helpful for unit tests but must + ABSOLUTELY NOT be used by plugins production code. +

+ */ @ParametersAreNonnullByDefault -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.internal; import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/function/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/package-info.java similarity index 89% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/function/package-info.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/package-info.java index 5c50525b275..919b1aa45fc 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/function/package-info.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/package-info.java @@ -17,7 +17,8 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ + @ParametersAreNonnullByDefault -package org.sonar.core.review.workflow.function; +package org.sonar.api.workflow; import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/screen/CommentScreen.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/screen/CommentScreen.java similarity index 90% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/screen/CommentScreen.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/screen/CommentScreen.java index 6bb253c1762..aff9df57e36 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/screen/CommentScreen.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/screen/CommentScreen.java @@ -17,11 +17,18 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.screen; +package org.sonar.api.workflow.screen; /** * Form with only a textarea field to type a comment. */ + +import com.google.common.annotations.Beta; + +/** + * @since 3.1 + */ +@Beta public final class CommentScreen extends Screen { public CommentScreen() { diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/screen/Screen.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/screen/Screen.java similarity index 93% rename from sonar-core/src/main/java/org/sonar/core/review/workflow/screen/Screen.java rename to sonar-plugin-api/src/main/java/org/sonar/api/workflow/screen/Screen.java index b37dbb3cb04..853a29a60d7 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/screen/Screen.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/screen/Screen.java @@ -17,7 +17,9 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.screen; +package org.sonar.api.workflow.screen; + +import com.google.common.annotations.Beta; /** *

Localization

@@ -26,7 +28,9 @@ package org.sonar.core.review.workflow.screen; *
  • the button in the violation toolbar that displays the form screen. Key is 'reviews.command..button'.
  • *
  • the button in the form screen that submits the command. Key is 'reviews.command..submit'.
  • * + * @since 3.1 */ +@Beta public abstract class Screen { private final String key; private String commandKey; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/workflow/screen/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/screen/package-info.java new file mode 100644 index 00000000000..f8f7e605f9c --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/workflow/screen/package-info.java @@ -0,0 +1,23 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +@ParametersAreNonnullByDefault +package org.sonar.api.workflow.screen; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/AdminRoleConditionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/AdminRoleConditionTest.java similarity index 89% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/condition/AdminRoleConditionTest.java rename to sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/AdminRoleConditionTest.java index f72c31ce0cd..9a6d9fe33b4 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/AdminRoleConditionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/AdminRoleConditionTest.java @@ -17,11 +17,11 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import org.junit.Test; -import org.sonar.core.review.workflow.review.DefaultReview; -import org.sonar.core.review.workflow.review.DefaultWorkflowContext; +import org.sonar.api.workflow.internal.DefaultReview; +import org.sonar.api.workflow.internal.DefaultWorkflowContext; import static org.fest.assertions.Assertions.assertThat; diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/ConditionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ConditionTest.java similarity index 90% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/condition/ConditionTest.java rename to sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ConditionTest.java index 9a3e74a4557..5fbb7d2d26a 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/ConditionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ConditionTest.java @@ -17,11 +17,11 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import org.junit.Test; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.review.WorkflowContext; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; import static org.fest.assertions.Assertions.assertThat; diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/ConditionsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ConditionsTest.java similarity index 98% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/condition/ConditionsTest.java rename to sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ConditionsTest.java index a0ad857405b..2c913d4752b 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/ConditionsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ConditionsTest.java @@ -17,7 +17,7 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import org.junit.Test; diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/HasProjectPropertyConditionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/HasProjectPropertyConditionTest.java similarity index 92% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/condition/HasProjectPropertyConditionTest.java rename to sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/HasProjectPropertyConditionTest.java index 541188cb47b..87c3a4fe70b 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/HasProjectPropertyConditionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/HasProjectPropertyConditionTest.java @@ -17,15 +17,16 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import org.junit.Test; import org.sonar.api.Properties; import org.sonar.api.Property; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.config.Settings; -import org.sonar.core.review.workflow.review.DefaultReview; -import org.sonar.core.review.workflow.review.DefaultWorkflowContext; +import org.sonar.api.workflow.internal.DefaultReview; +import org.sonar.api.workflow.internal.DefaultWorkflowContext; + import static org.fest.assertions.Assertions.assertThat; diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/HasReviewPropertyConditionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/HasReviewPropertyConditionTest.java similarity index 91% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/condition/HasReviewPropertyConditionTest.java rename to sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/HasReviewPropertyConditionTest.java index ebc0fb7d042..1f578549024 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/HasReviewPropertyConditionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/HasReviewPropertyConditionTest.java @@ -17,13 +17,13 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.core.review.workflow.review.DefaultReview; -import org.sonar.core.review.workflow.review.DefaultWorkflowContext; +import org.sonar.api.workflow.internal.DefaultReview; +import org.sonar.api.workflow.internal.DefaultWorkflowContext; import static org.fest.assertions.Assertions.assertThat; diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/NotConditionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/NotConditionTest.java similarity index 84% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/condition/NotConditionTest.java rename to sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/NotConditionTest.java index 46ac81f5acd..1b73fc7723c 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/NotConditionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/NotConditionTest.java @@ -17,13 +17,13 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import org.junit.Test; -import org.sonar.core.review.workflow.review.DefaultReview; -import org.sonar.core.review.workflow.review.DefaultWorkflowContext; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.review.WorkflowContext; +import org.sonar.api.workflow.internal.DefaultReview; +import org.sonar.api.workflow.internal.DefaultWorkflowContext; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; import static org.fest.assertions.Assertions.assertThat; diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/ProjectPropertyConditionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ProjectPropertyConditionTest.java similarity index 88% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/condition/ProjectPropertyConditionTest.java rename to sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ProjectPropertyConditionTest.java index 86d7c279b31..7e3344d528a 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/ProjectPropertyConditionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ProjectPropertyConditionTest.java @@ -17,11 +17,11 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import org.junit.Test; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.review.WorkflowContext; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.WorkflowContext; import static org.fest.assertions.Assertions.assertThat; diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/ResolutionConditionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ResolutionConditionTest.java similarity index 89% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/condition/ResolutionConditionTest.java rename to sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ResolutionConditionTest.java index caa79784e3c..17b44272931 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/ResolutionConditionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ResolutionConditionTest.java @@ -17,14 +17,14 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.core.review.workflow.review.DefaultReview; -import org.sonar.core.review.workflow.review.DefaultWorkflowContext; -import org.sonar.core.review.workflow.review.Review; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.internal.DefaultReview; +import org.sonar.api.workflow.internal.DefaultWorkflowContext; import static org.fest.assertions.Assertions.assertThat; diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/StatusConditionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/StatusConditionTest.java similarity index 89% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/condition/StatusConditionTest.java rename to sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/StatusConditionTest.java index 46c2a2c5ed5..2fcc17a49ed 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/condition/StatusConditionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/StatusConditionTest.java @@ -17,14 +17,14 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.condition; +package org.sonar.api.workflow.condition; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.core.review.workflow.review.DefaultReview; -import org.sonar.core.review.workflow.review.DefaultWorkflowContext; -import org.sonar.core.review.workflow.review.Review; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.internal.DefaultReview; +import org.sonar.api.workflow.internal.DefaultWorkflowContext; import static org.fest.assertions.Assertions.assertThat; diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/function/CommentFunctionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/function/CommentFunctionTest.java similarity index 88% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/function/CommentFunctionTest.java rename to sonar-plugin-api/src/test/java/org/sonar/api/workflow/function/CommentFunctionTest.java index bfb464298ce..3970f22b809 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/function/CommentFunctionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/function/CommentFunctionTest.java @@ -17,13 +17,13 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.function; +package org.sonar.api.workflow.function; import com.google.common.collect.Maps; import org.junit.Test; -import org.sonar.core.review.workflow.review.Comment; -import org.sonar.core.review.workflow.review.DefaultReview; -import org.sonar.core.review.workflow.review.DefaultWorkflowContext; +import org.sonar.api.workflow.Comment; +import org.sonar.api.workflow.internal.DefaultReview; +import org.sonar.api.workflow.internal.DefaultWorkflowContext; import java.util.List; import java.util.Map; diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/WorkflowTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/internal/DefaultWorkflowTest.java similarity index 80% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/WorkflowTest.java rename to sonar-plugin-api/src/test/java/org/sonar/api/workflow/internal/DefaultWorkflowTest.java index 00502cd6148..69bd7711d23 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/WorkflowTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/internal/DefaultWorkflowTest.java @@ -17,29 +17,30 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow; +package org.sonar.api.workflow.internal; import org.fest.assertions.MapAssert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.core.review.workflow.condition.Condition; -import org.sonar.core.review.workflow.condition.HasProjectPropertyCondition; -import org.sonar.core.review.workflow.condition.StatusCondition; -import org.sonar.core.review.workflow.function.CommentFunction; -import org.sonar.core.review.workflow.function.Function; -import org.sonar.core.review.workflow.screen.CommentScreen; +import org.sonar.api.workflow.Workflow; +import org.sonar.api.workflow.condition.Condition; +import org.sonar.api.workflow.condition.HasProjectPropertyCondition; +import org.sonar.api.workflow.condition.StatusCondition; +import org.sonar.api.workflow.function.CommentFunction; +import org.sonar.api.workflow.function.Function; +import org.sonar.api.workflow.screen.CommentScreen; import static org.fest.assertions.Assertions.assertThat; -public class WorkflowTest { +public class DefaultWorkflowTest { @Rule public ExpectedException thrown = ExpectedException.none(); @Test public void addCommand() { - Workflow workflow = new Workflow(); + DefaultWorkflow workflow = new DefaultWorkflow(); assertThat(workflow.getCommands()).isEmpty(); assertThat(workflow.addCommand("resolve")).isSameAs(workflow); @@ -52,13 +53,13 @@ public class WorkflowTest { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Empty command key"); - Workflow workflow = new Workflow(); + Workflow workflow = new DefaultWorkflow(); workflow.addCommand(""); } @Test public void addSeveralTimesTheSameCommand() { - Workflow workflow = new Workflow(); + Workflow workflow = new DefaultWorkflow(); workflow.addCommand("resolve"); workflow.addCommand("resolve"); assertThat(workflow.getCommands()).containsOnly("resolve"); @@ -70,13 +71,13 @@ public class WorkflowTest { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Unknown command: resolve"); - Workflow workflow = new Workflow(); + Workflow workflow = new DefaultWorkflow(); workflow.addCondition("resolve", new StatusCondition("OPEN")); } @Test public void addCondition() { - Workflow workflow = new Workflow(); + Workflow workflow = new DefaultWorkflow(); Condition condition = new StatusCondition("OPEN"); workflow.addCommand("resolve"); @@ -87,13 +88,13 @@ public class WorkflowTest { @Test public void getConditions_empty() { - Workflow workflow = new Workflow(); + Workflow workflow = new DefaultWorkflow(); assertThat(workflow.getConditions("resolve")).isEmpty(); } @Test public void keepCacheOfProjectPropertiesRequiredByConditions() { - Workflow workflow = new Workflow(); + DefaultWorkflow workflow = new DefaultWorkflow(); Condition condition1 = new HasProjectPropertyCondition("jira.url"); Condition condition2 = new HasProjectPropertyCondition("jira.login"); workflow.addCommand("create-jira-issue"); @@ -105,14 +106,14 @@ public class WorkflowTest { @Test public void cacheOfProjectPropertiesIsNotNull() { - Workflow workflow = new Workflow(); + DefaultWorkflow workflow = new DefaultWorkflow(); assertThat(workflow.getProjectPropertyKeys()).isEmpty(); } @Test public void keepFastLinksToReviewAndContextConditions() { - Workflow workflow = new Workflow(); + DefaultWorkflow workflow = new DefaultWorkflow(); workflow.addCommand("create-jira-issue"); Condition contextCondition = new HasProjectPropertyCondition("jira.url"); workflow.addCondition("create-jira-issue", contextCondition); @@ -125,7 +126,7 @@ public class WorkflowTest { @Test public void addFunction() { - Workflow workflow = new Workflow(); + Workflow workflow = new DefaultWorkflow(); workflow.addCommand("resolve"); Function function = new CommentFunction(); @@ -136,7 +137,7 @@ public class WorkflowTest { @Test public void getFunctions_empty() { - Workflow workflow = new Workflow(); + Workflow workflow = new DefaultWorkflow(); assertThat(workflow.getFunctions("resolve")).isEmpty(); } @@ -145,7 +146,7 @@ public class WorkflowTest { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Unknown command: resolve"); - Workflow workflow = new Workflow(); + Workflow workflow = new DefaultWorkflow(); workflow.addFunction("resolve", new CommentFunction()); } @@ -154,13 +155,13 @@ public class WorkflowTest { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Unknown command: resolve"); - Workflow workflow = new Workflow(); + Workflow workflow = new DefaultWorkflow(); workflow.setScreen("resolve", new CommentScreen()); } @Test public void setScreen() { - Workflow workflow = new Workflow(); + DefaultWorkflow workflow = new DefaultWorkflow(); workflow.addCommand("resolve"); CommentScreen screen = new CommentScreen(); workflow.setScreen("resolve", screen); diff --git a/sonar-core/src/test/java/org/sonar/core/review/workflow/screen/CommentScreenTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/screen/CommentScreenTest.java similarity index 96% rename from sonar-core/src/test/java/org/sonar/core/review/workflow/screen/CommentScreenTest.java rename to sonar-plugin-api/src/test/java/org/sonar/api/workflow/screen/CommentScreenTest.java index db448b37d7a..1404bfc6de0 100644 --- a/sonar-core/src/test/java/org/sonar/core/review/workflow/screen/CommentScreenTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/screen/CommentScreenTest.java @@ -17,7 +17,7 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.core.review.workflow.screen; +package org.sonar.api.workflow.screen; import org.junit.Test; diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index 1542bb10aaa..26981427754 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -19,6 +19,7 @@ */ package org.sonar.server.platform; +import org.sonar.api.workflow.internal.DefaultWorkflow; import org.sonar.server.startup.RegisterNewFilters; import org.apache.commons.configuration.BaseConfiguration; @@ -44,9 +45,8 @@ import org.sonar.core.metric.DefaultMetricFinder; import org.sonar.core.notification.DefaultNotificationManager; import org.sonar.core.persistence.*; import org.sonar.core.qualitymodel.DefaultModelFinder; -import org.sonar.core.review.workflow.ReviewDatabaseStore; -import org.sonar.core.review.workflow.WorkflowEngine; -import org.sonar.core.review.workflow.Workflow; +import org.sonar.core.workflow.ReviewDatabaseStore; +import org.sonar.core.workflow.WorkflowEngine; import org.sonar.core.rule.DefaultRuleFinder; import org.sonar.core.user.DefaultUserFinder; import org.sonar.jpa.dao.MeasuresDao; @@ -176,7 +176,7 @@ public final class Platform { ServerExtensionInstaller extensionRegistrar = servicesContainer.getComponentByType(ServerExtensionInstaller.class); extensionRegistrar.registerExtensions(servicesContainer); - servicesContainer.addSingleton(Workflow.class); + servicesContainer.addSingleton(DefaultWorkflow.class); servicesContainer.addSingleton(ReviewDatabaseStore.class); servicesContainer.addSingleton(WorkflowEngine.class); diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index b639339f1bf..a2a73f25d9c 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -43,11 +43,11 @@ import org.sonar.core.persistence.Database; import org.sonar.core.persistence.DatabaseMigrator; import org.sonar.core.purge.PurgeDao; import org.sonar.core.resource.ResourceIndexerDao; -import org.sonar.core.review.workflow.WorkflowEngine; -import org.sonar.core.review.workflow.review.DefaultReview; -import org.sonar.core.review.workflow.review.DefaultWorkflowContext; -import org.sonar.core.review.workflow.review.Review; -import org.sonar.core.review.workflow.screen.Screen; +import org.sonar.core.workflow.WorkflowEngine; +import org.sonar.api.workflow.internal.DefaultReview; +import org.sonar.api.workflow.internal.DefaultWorkflowContext; +import org.sonar.api.workflow.Review; +import org.sonar.api.workflow.screen.Screen; import org.sonar.markdown.Markdown; import org.sonar.server.configuration.Backup; import org.sonar.server.configuration.ProfilesManager; diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/api/review_context.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/api/review_context.rb index 54b68249b94..6fd158983ff 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/api/review_context.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/api/review_context.rb @@ -33,7 +33,7 @@ class Api::ReviewContext def initialize(options={}) - @review = options[:review] + @review = options[:workflow] @project = options[:project] @user = options[:user] @params = options[:params] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb index 6ae29910d0b..72a1d405f72 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb @@ -275,7 +275,7 @@ class RuleFailure < ActiveRecord::Base end def self.to_java_workflow_review(violation) - java_review=Java::OrgSonarCoreReviewWorkflowReview::DefaultReview.new + java_review=Java::OrgSonarApiWorkflowInternal::DefaultReview.new java_review.setViolationId(violation.id) java_review.setSeverity(violation.severity.to_s) java_review.setRuleKey(violation.rule.plugin_rule_key) @@ -299,7 +299,7 @@ class RuleFailure < ActiveRecord::Base end def self.to_java_workflow_context(project, user) - java_context = Java::OrgSonarCoreReviewWorkflowReview::DefaultWorkflowContext.new + java_context = Java::OrgSonarApiWorkflowInternal::DefaultWorkflowContext.new java_context.setUserId(user.id) java_context.setUserLogin(user.login) java_context.setUserName(user.name) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_view.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_view.html.erb index 7f52dafd51a..b274fc3672f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_view.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_view.html.erb @@ -3,5 +3,5 @@ # hack in case 'error_message' is nil (this should disappear when refactoring the '_view' and '_review' partials) error_message = error_message %> - <%= render :partial => 'project_reviews/review', :locals => {:review => @review, :error_message => error_message} -%> + <%= render :partial => 'project_reviews/review', :locals => {:workflow => @review, :error_message => error_message} -%> -- 2.39.5