aboutsummaryrefslogtreecommitdiffstats
path: root/it
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-10-09 17:43:56 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-10-09 17:44:26 +0200
commite2744e0879cc6fbefb79aec2ff1d45cc776ae3e0 (patch)
treedcff1d15bfd5da9608987744c510509f3e92410d /it
parent5f55b99162dd6aeab57aec9f0b6c8159ecba6dea (diff)
downloadsonarqube-e2744e0879cc6fbefb79aec2ff1d45cc776ae3e0.tar.gz
sonarqube-e2744e0879cc6fbefb79aec2ff1d45cc776ae3e0.zip
SONAR-6717 Add IT to check that issue attribute is kept on next analysis
Diffstat (limited to 'it')
-rw-r--r--it/it-plugins/issue-action-plugin/src/main/java/ActionDefinition.java11
-rw-r--r--it/it-tests/src/test/java/issue/suite/IssueActionTest.java19
2 files changed, 28 insertions, 2 deletions
diff --git a/it/it-plugins/issue-action-plugin/src/main/java/ActionDefinition.java b/it/it-plugins/issue-action-plugin/src/main/java/ActionDefinition.java
index 84f5e6c5a6a..1af4f7ef152 100644
--- a/it/it-plugins/issue-action-plugin/src/main/java/ActionDefinition.java
+++ b/it/it-plugins/issue-action-plugin/src/main/java/ActionDefinition.java
@@ -22,10 +22,14 @@ import org.sonar.api.ServerExtension;
import org.sonar.api.issue.Issue;
import org.sonar.api.issue.action.Actions;
import org.sonar.api.issue.action.Function;
+import org.sonar.api.issue.condition.HasIssuePropertyCondition;
import org.sonar.api.issue.condition.HasResolution;
+import org.sonar.api.issue.condition.NotCondition;
public class ActionDefinition implements ServerExtension {
+ public static final String FAKE_PROPERTY = "fake";
+
private final Actions actions;
public ActionDefinition(Actions actions) {
@@ -34,11 +38,14 @@ public class ActionDefinition implements ServerExtension {
public void start() {
actions.add("fake")
- .setConditions(new HasResolution(Issue.RESOLUTION_FIXED))
+ .setConditions(
+ new HasResolution(Issue.RESOLUTION_FIXED),
+ new NotCondition(new HasIssuePropertyCondition(FAKE_PROPERTY))
+ )
.setFunctions(new Function() {
@Override
public void execute(Context context) {
- context.setAttribute("fake", "fake action");
+ context.setAttribute(FAKE_PROPERTY, "fake action");
context.addComment("New Comment from fake action");
}
});
diff --git a/it/it-tests/src/test/java/issue/suite/IssueActionTest.java b/it/it-tests/src/test/java/issue/suite/IssueActionTest.java
index ab23ce589fe..c6d1b75e982 100644
--- a/it/it-tests/src/test/java/issue/suite/IssueActionTest.java
+++ b/it/it-tests/src/test/java/issue/suite/IssueActionTest.java
@@ -252,6 +252,25 @@ public class IssueActionTest {
assertThat(reloaded.comments()).hasSize(1);
assertThat(reloaded.comments().get(0).htmlText()).isEqualTo("New Comment from fake action");
+
+ // The action is no more available when already executed (because an issue attribute is used to check if the action is available or not)
+ assertThat(adminIssueClient().actions(issue.key())).doesNotContain("fake");
+ }
+
+ /**
+ * SONAR-4315
+ */
+ @Test
+ public void issue_attribute_are_kept_on_new_analysis() {
+ // The condition on the action defined by the plugin is that the status must be resolved
+ adminIssueClient().doTransition(issue.key(), "resolve");
+ adminIssueClient().doAction(issue.key(), "fake");
+ assertThat(adminIssueClient().actions(issue.key())).doesNotContain("fake");
+
+ orchestrator.executeBuild(scan);
+
+ // Fake action is no more available if the issue attribute is still there
+ assertThat(adminIssueClient().actions(issue.key())).doesNotContain("fake");
}
}