]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6717 Drop issue.Action API
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 31 Mar 2016 14:27:21 +0000 (16:27 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 31 Mar 2016 14:55:01 +0000 (16:55 +0200)
server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Action.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Actions.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Function.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/issue/action/package-info.java [deleted file]
sonar-plugin-api/src/test/java/org/sonar/api/issue/action/ActionTest.java [deleted file]
sonar-plugin-api/src/test/java/org/sonar/api/issue/action/ActionsTest.java [deleted file]
sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/tasks/TasksMediumTest.java

index bd2d9e11eb0daee1e06800d11d8c8ef92044de23..cc98def1ecf399c8d80cd8694a8fcf0190e09a1c 100644 (file)
@@ -24,7 +24,6 @@ import java.util.List;
 import javax.annotation.CheckForNull;
 import org.sonar.api.config.EmailSettings;
 import org.sonar.api.internal.SonarQubeVersionFactory;
-import org.sonar.api.issue.action.Actions;
 import org.sonar.api.profiles.AnnotationProfileParser;
 import org.sonar.api.profiles.XMLProfileParser;
 import org.sonar.api.profiles.XMLProfileSerializer;
@@ -426,7 +425,6 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
     // InternalRubyIssueService.class, indirectly used only in Web Services
     // IssueChangelogService.class, indirectly used only in Web Services
     // ActionService.class, indirectly used only in Web Services
-    Actions.class,
     // IssueBulkChangeService.class, indirectly used only in Web Services
     // WsResponseCommonFormat.class, indirectly used only in Web Services
     // IssueWsModule.class, no Web Service in CE
index 15abf853225a58d11a09eb3f997e49a3ef032671..4345cd88fe447aeed70d306ab6d8804f33112dd8 100644 (file)
@@ -79,7 +79,7 @@ public class ComputeEngineContainerImplTest {
     assertThat(picoContainer.getComponentAdapters())
       .hasSize(
         CONTAINER_ITSELF
-          + 76 // level 4
+          + 75 // level 4
           + 5 // content of CeModule
           + 7 // content of CeQueueModule
           + 4 // content of ReportProcessingModule
index 10913fa94ca695e5e625e6067c9d56c118e0c648..7d4549f10a8a056f41757f40377be0fdc17e34ff 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.server.platform.platformlevel;
 
 import java.util.List;
 import org.sonar.api.config.EmailSettings;
-import org.sonar.api.issue.action.Actions;
 import org.sonar.api.profiles.AnnotationProfileParser;
 import org.sonar.api.profiles.XMLProfileParser;
 import org.sonar.api.profiles.XMLProfileSerializer;
@@ -556,7 +555,6 @@ public class PlatformLevel4 extends PlatformLevel {
       InternalRubyIssueService.class,
       IssueChangelogService.class,
       ActionService.class,
-      Actions.class,
       IssueBulkChangeService.class,
       WsResponseCommonFormat.class,
       IssueWsModule.class,
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Action.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Action.java
deleted file mode 100644 (file)
index 9112f6c..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.api.issue.action;
-
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableList;
-import java.util.List;
-import org.sonar.api.issue.Issue;
-import org.sonar.api.issue.condition.Condition;
-
-import static com.google.common.collect.Lists.newArrayList;
-
-/**
- * @since 3.6
- * @deprecated in 5.5. Webapp cannot be customized anymore to define actions on issues
- */
-@Deprecated
-public class Action {
-
-  private final String key;
-  private final List<Condition> conditions;
-  private final List<Function> functions;
-
-  Action(String key) {
-    Preconditions.checkArgument(!Strings.isNullOrEmpty(key), "Action key must be set");
-    this.key = key;
-    this.conditions = newArrayList();
-    this.functions = newArrayList();
-  }
-
-  public String key() {
-    return key;
-  }
-
-  public Action setConditions(Condition... conditions) {
-    this.conditions.addAll(ImmutableList.copyOf(conditions));
-    return this;
-  }
-
-  public List<Condition> conditions() {
-    return conditions;
-  }
-
-  public Action setFunctions(Function... functions) {
-    this.functions.addAll(ImmutableList.copyOf(functions));
-    return this;
-  }
-
-  public List<Function> functions() {
-    return functions;
-  }
-
-  public boolean supports(Issue issue) {
-    for (Condition condition : conditions) {
-      if (!condition.matches(issue)) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) {
-      return true;
-    }
-    if (o == null || getClass() != o.getClass()) {
-      return false;
-    }
-    Action that = (Action) o;
-    return key.equals(that.key);
-  }
-
-  @Override
-  public int hashCode() {
-    return key.hashCode();
-  }
-
-  @Override
-  public String toString() {
-    return key;
-  }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Actions.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Actions.java
deleted file mode 100644 (file)
index 29dd04c..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.api.issue.action;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.sonar.api.server.ServerSide;
-
-/**
- * @since 3.6
- * @deprecated in 5.5. Webapp cannot be customized anymore to define actions on issues
- */
-@Deprecated
-@ServerSide
-public class Actions {
-
-  private final List<Action> list = new ArrayList<>();
-
-  public Action add(String actionKey) {
-    Action action = new Action(actionKey);
-    this.list.add(action);
-    return action;
-  }
-
-  public List<Action> list() {
-    return list;
-  }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Function.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Function.java
deleted file mode 100644 (file)
index d0e1a99..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.api.issue.action;
-
-import com.google.common.annotations.Beta;
-import org.sonar.api.config.Settings;
-import org.sonar.api.issue.Issue;
-
-import javax.annotation.Nullable;
-
-/**
- * @since 3.6
- */
-@Beta
-public interface Function {
-
-  void execute(Context context);
-
-  interface Context {
-    Issue issue();
-
-    Settings projectSettings();
-
-    Context setAttribute(String key, @Nullable String value);
-
-    Context addComment(@Nullable String text);
-  }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/package-info.java
deleted file mode 100644 (file)
index 700451e..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.api.issue.action;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/action/ActionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/action/ActionTest.java
deleted file mode 100644 (file)
index e0ac8af..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.api.issue.action;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.issue.Issue;
-import org.sonar.api.issue.condition.Condition;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ActionTest {
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
-  Condition condition1 = mock(Condition.class);
-  Condition condition2 = mock(Condition.class);
-  Function function1 = mock(Function.class);
-  Function function2 = mock(Function.class);
-
-  @Test
-  public void test_action() throws Exception {
-    Action action = new Action("link-to-jira")
-      .setConditions(condition1, condition2)
-      .setFunctions(function1, function2);
-
-    assertThat(action.key()).isEqualTo("link-to-jira");
-    assertThat(action.conditions()).containsOnly(condition1, condition2);
-    assertThat(action.functions()).containsOnly(function1, function2);
-  }
-
-  @Test
-  public void key_should_be_set() {
-    thrown.expectMessage("Action key must be set");
-
-    new Action("");
-  }
-
-  @Test
-  public void should_verify_conditions() {
-    Issue issue = mock(Issue.class);
-    Action action = new Action("link-to-jira")
-      .setConditions(condition1, condition2);
-
-    when(condition1.matches(issue)).thenReturn(true);
-    when(condition2.matches(issue)).thenReturn(false);
-    assertThat(action.supports(issue)).isFalse();
-
-    when(condition1.matches(issue)).thenReturn(true);
-    when(condition2.matches(issue)).thenReturn(true);
-    assertThat(action.supports(issue)).isTrue();
-  }
-
-  @Test
-  public void test_equals_and_hashCode() throws Exception {
-    Action t1 = new Action("link-to-jira");
-    Action t2 = new Action("link-to-jira");
-    Action t3 = new Action("comment");
-
-    assertThat(t1).isEqualTo(t1);
-    assertThat(t1).isEqualTo(t2);
-    assertThat(t1).isNotEqualTo(t3);
-
-    assertThat(t1.hashCode()).isEqualTo(t1.hashCode());
-  }
-
-  @Test
-  public void test_toString() throws Exception {
-    Action t1 = new Action("link-to-jira");
-    assertThat(t1.toString()).isEqualTo("link-to-jira");
-  }
-
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/action/ActionsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/action/ActionsTest.java
deleted file mode 100644 (file)
index 522ebba..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.api.issue.action;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class ActionsTest {
-
-  @Test
-  public void add_action() {
-    Actions actions = new Actions();
-    actions.add("assign");
-
-    assertThat(actions.list()).hasSize(1);
-  }
-
-}
index 766e9371898d0a077e401a880f0af4915d2316cf..0918a21db03cf866ce688981760fd12004697123 100644 (file)
@@ -28,7 +28,6 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.api.SonarPlugin;
-import org.sonar.api.issue.action.Actions;
 import org.sonar.api.task.Task;
 import org.sonar.api.task.TaskDefinition;
 import org.sonar.api.utils.MessageException;
@@ -106,18 +105,6 @@ public class TasksMediumTest {
       .start();
   }
 
-  private void startServer(Integer responseStatus, String responseData) throws Exception {
-    server = new MockHttpServer();
-    server.start();
-
-    if (responseStatus != null) {
-      server.setMockResponseStatus(responseStatus);
-    }
-    if (responseData != null) {
-      server.setMockResponseData(responseData);
-    }
-  }
-
   private static class FakeTaskPlugin extends SonarPlugin {
 
     @Override
@@ -142,17 +129,10 @@ public class TasksMediumTest {
   private static class BrokenTask implements Task {
 
     public static final TaskDefinition DEF = TaskDefinition.builder().key("broken").description("Broken description").taskClass(BrokenTask.class).build();
-    private final Actions serverSideComponent;
-
-    public BrokenTask(Actions serverSideComponent) {
-      this.serverSideComponent = serverSideComponent;
-    }
 
     @Override
     public void execute() {
-      System.out.println(serverSideComponent.list());
-      ;
-
+      // do nothing
     }
 
   }