]> source.dussan.org Git - sonarqube.git/commitdiff
Drop unused internal WS api/activities/search
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 1 Aug 2016 21:05:06 +0000 (23:05 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 2 Aug 2016 08:03:30 +0000 (10:03 +0200)
Replaced by api/qualityprofiles/changelog

12 files changed:
server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
server/sonar-server/src/main/java/org/sonar/server/activity/Activity.java
server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivitiesWs.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivityMapping.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/activity/ws/package-info.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
server/sonar-server/src/main/resources/org/sonar/server/activity/ws/search-example.json [deleted file]
server/sonar-server/src/test/java/org/sonar/server/activity/ActivityServiceTest.java
server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/activity/ws/ActivitiesWsMediumTest.java [deleted file]

index 56b29de5decf7d2d440dccdbf664c8f204a45d1e..8c8b06ad6535055684b961386a8cfe2acd5ffd7a 100644 (file)
@@ -393,11 +393,6 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
       // org.sonar.server.language.ws.ListAction.class, no Web Service in CE
       // LanguageWs.class, no Web Service in CE
 
-      // activity
-      // ActivityMapping.class, no Web Service in CE
-      // org.sonar.server.activity.ws.SearchAction.class, no Web Service in CE
-      // ActivitiesWs.class, no Web Service in CE
-
       // measure
       // MeasureFilterFactory.class, used only in MeasureFilterEngine
       // MeasureFilterExecutor.class, used only in MeasureFilterEngine
index 3c05da730fef879e41bbe4d48fcf1d1c4512100f..94ef2824bd97bc61659ca4ab9fa123ba0111f0b5 100644 (file)
@@ -27,7 +27,7 @@ import javax.annotation.Nullable;
 public class Activity {
 
   public enum Type {
-    QPROFILE, ANALYSIS_REPORT
+    QPROFILE
   }
 
   private Type type;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivitiesWs.java b/server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivitiesWs.java
deleted file mode 100644 (file)
index 320fae1..0000000
+++ /dev/null
@@ -1,43 +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.server.activity.ws;
-
-import org.sonar.api.server.ws.WebService;
-
-public class ActivitiesWs implements WebService {
-
-  public static final String ENDPOINT = "api/activities";
-
-  private final SearchAction search;
-
-  public ActivitiesWs(SearchAction search) {
-    this.search = search;
-  }
-
-  @Override
-  public void define(Context context) {
-    NewController controller = context
-      .createController(ENDPOINT)
-      .setDescription("Track activities.");
-
-    search.define(controller);
-    controller.done();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivityMapping.java b/server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivityMapping.java
deleted file mode 100644 (file)
index 67afe62..0000000
+++ /dev/null
@@ -1,57 +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.server.activity.ws;
-
-import java.util.Map;
-import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.server.activity.index.ActivityDoc;
-import org.sonar.server.activity.index.ActivityIndexDefinition;
-import org.sonar.server.search.QueryContext;
-import org.sonar.server.search.ws.BaseMapping;
-
-/**
- * Conversion between {@link org.sonar.server.activity.index.ActivityDoc} and WS JSON response
- */
-public class ActivityMapping extends BaseMapping<ActivityDoc, Object> {
-
-  public ActivityMapping() {
-    super();
-    map("type", ActivityIndexDefinition.FIELD_TYPE);
-    map("action", ActivityIndexDefinition.FIELD_ACTION);
-    mapDateTime("createdAt", ActivityIndexDefinition.FIELD_CREATED_AT);
-    map("login", ActivityIndexDefinition.FIELD_LOGIN);
-    map("message", ActivityIndexDefinition.FIELD_MESSAGE);
-    map("details", new IndexMapper<ActivityDoc, Object>(ActivityIndexDefinition.FIELD_DETAILS) {
-      @Override
-      public void write(JsonWriter json, ActivityDoc activity, Object context) {
-        json.name("details").beginObject();
-        for (Map.Entry<String, String> detail : activity.getDetails().entrySet()) {
-          json.prop(detail.getKey(), detail.getValue());
-        }
-        json.endObject();
-      }
-    });
-  }
-
-  public void write(ActivityDoc activity, JsonWriter writer, QueryContext context) {
-    doWrite(activity, null, writer, context);
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java
deleted file mode 100644 (file)
index 1621ade..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.server.activity.ws;
-
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.RequestHandler;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.server.activity.Activity;
-import org.sonar.server.activity.index.ActivityDoc;
-import org.sonar.server.activity.index.ActivityIndex;
-import org.sonar.server.activity.index.ActivityQuery;
-import org.sonar.server.es.SearchOptions;
-import org.sonar.server.es.SearchResult;
-import org.sonar.server.search.QueryContext;
-import org.sonar.server.user.UserSession;
-
-import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
-
-public class SearchAction implements RequestHandler {
-
-  public static final String PARAM_TYPE = "type";
-  public static final String SEARCH_ACTION = "search";
-
-  private final ActivityIndex activityIndex;
-  private final ActivityMapping docToJsonMapping;
-  private final UserSession userSession;
-
-  public SearchAction(ActivityIndex activityIndex, ActivityMapping docToJsonMapping, UserSession userSession) {
-    this.activityIndex = activityIndex;
-    this.docToJsonMapping = docToJsonMapping;
-    this.userSession = userSession;
-  }
-
-  void define(WebService.NewController controller) {
-    WebService.NewAction action = controller
-      .createAction(SEARCH_ACTION)
-      .setDescription("Search for activities")
-      .setSince("4.4")
-      .setResponseExample(getClass().getResource("search-example.json"))
-      .setInternal(true)
-      .setHandler(this);
-
-    action.createParam(PARAM_TYPE)
-      .setDescription("Activity type")
-      .setPossibleValues(Activity.Type.values());
-
-    action.addPagingParams(10, MAX_LIMIT);
-    action.addFieldsParam(docToJsonMapping.supportedFields());
-  }
-
-  @Override
-  public void handle(Request request, Response response) {
-    ActivityQuery query = new ActivityQuery();
-    query.setTypes(request.paramAsStrings(PARAM_TYPE));
-
-    SearchOptions options = new SearchOptions();
-    options.setPage(request.mandatoryParamAsInt(WebService.Param.PAGE), request.mandatoryParamAsInt(WebService.Param.PAGE_SIZE));
-
-    SearchResult<ActivityDoc> results = activityIndex.search(query, options);
-
-    JsonWriter json = response.newJsonWriter().beginObject();
-    options.writeJson(json, results.getTotal());
-    writeActivities(results, json, new QueryContext(userSession).setFieldsToReturn(request.paramAsStrings(WebService.Param.FIELDS)));
-    json.endObject().close();
-  }
-
-  private void writeActivities(SearchResult<ActivityDoc> docs, JsonWriter json, QueryContext context) {
-    json.name("logs").beginArray();
-    for (ActivityDoc doc : docs.getDocs()) {
-      docToJsonMapping.write(doc, json, context);
-    }
-    json.endArray();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/activity/ws/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/activity/ws/package-info.java
deleted file mode 100644 (file)
index 66aa6b0..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.server.activity.ws;
-
-import javax.annotation.ParametersAreNonnullByDefault;
index ef0e64a91375314752133a3fc3056e03695e0e55..015abc77720ed3e0c4c9828aec39bfe6c7807b17 100644 (file)
@@ -37,8 +37,6 @@ import org.sonar.server.activity.ActivityService;
 import org.sonar.server.activity.index.ActivityIndex;
 import org.sonar.server.activity.index.ActivityIndexDefinition;
 import org.sonar.server.activity.index.ActivityIndexer;
-import org.sonar.server.activity.ws.ActivitiesWs;
-import org.sonar.server.activity.ws.ActivityMapping;
 import org.sonar.server.authentication.AuthenticationModule;
 import org.sonar.server.batch.BatchWsModule;
 import org.sonar.server.ce.ws.CeWsModule;
@@ -431,11 +429,6 @@ public class PlatformLevel4 extends PlatformLevel {
       LanguageWs.class,
       org.sonar.server.language.ws.ListAction.class,
 
-      // activity
-      ActivitiesWs.class,
-      org.sonar.server.activity.ws.SearchAction.class,
-      ActivityMapping.class,
-
       // measure
       MeasureFilterFactory.class,
       MeasureFilterExecutor.class,
index ff3c7eb23f5126f459289d11005f860b25effa51..e5f3911c31d47e5491d1502bf67bc197852dd89d 100644 (file)
@@ -34,7 +34,6 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.qualityprofile.ActiveRuleKey;
 import org.sonar.db.qualityprofile.QualityProfileDto;
-import org.sonar.server.activity.index.ActivityIndex;
 import org.sonar.server.qualityprofile.index.ActiveRuleIndexer;
 import org.sonar.server.rule.index.RuleQuery;
 import org.sonar.server.user.UserSession;
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/activity/ws/search-example.json b/server/sonar-server/src/main/resources/org/sonar/server/activity/ws/search-example.json
deleted file mode 100644 (file)
index 2a67014..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-{
-  "total": 8817,
-  "p": 1,
-  "ps": 10,
-  "logs": [
-    {
-      "key": "AVC0aUZtVSHMD73TCQ9n",
-      "type": "QPROFILE",
-      "action": "UPDATED",
-      "createdAt": "2015-10-29T17:23:29+0100",
-      "login": "freddy.mallet",
-      "details": {
-        "profileKey": "java-default-with-mojo-conventions-49307",
-        "severity": "MAJOR",
-        "param_indentationLevel": "4",
-        "inheritance": "OVERRIDES",
-        "ruleKey": "squid:IndentationCheck",
-        "key": "java-default-with-mojo-conventions-49307:squid:IndentationCheck"
-      }
-    },
-    {
-      "key": "AVCUXEw_dBKrKCzZ3xlU",
-      "type": "QPROFILE",
-      "action": "ACTIVATED",
-      "createdAt": "2015-10-23T13:01:28+0200",
-      "login": "ann.campbell",
-      "details": {
-        "profileKey": "java-for-sq-only-95381",
-        "severity": "MAJOR",
-        "inheritance": "INHERITED",
-        "ruleKey": "squid:S2293",
-        "key": "java-for-sq-only-95381:squid:S2293"
-      }
-    },
-    {
-      "key": "AVCUXEwEdBKrKCzZ3xlT",
-      "type": "QPROFILE",
-      "action": "ACTIVATED",
-      "createdAt": "2015-10-23T13:01:28+0200",
-      "login": "ann.campbell",
-      "details": {
-        "profileKey": "java-for-sq-java-plugin-only-92289",
-        "severity": "MAJOR",
-        "inheritance": "INHERITED",
-        "ruleKey": "squid:S2293",
-        "key": "java-for-sq-java-plugin-only-92289:squid:S2293"
-      }
-    },
-    {
-      "key": "AVCUXEvfdBKrKCzZ3xlS",
-      "type": "QPROFILE",
-      "action": "ACTIVATED",
-      "createdAt": "2015-10-23T13:01:28+0200",
-      "login": "ann.campbell",
-      "details": {
-        "profileKey": "java-default-with-sonarsource-conventions-27339",
-        "severity": "MAJOR",
-        "inheritance": "INHERITED",
-        "ruleKey": "squid:S2293",
-        "key": "java-default-with-sonarsource-conventions-27339:squid:S2293"
-      }
-    },
-    {
-      "key": "AVCUXEu6dBKrKCzZ3xlR",
-      "type": "QPROFILE",
-      "action": "ACTIVATED",
-      "createdAt": "2015-10-23T13:01:28+0200",
-      "login": "ann.campbell",
-      "details": {
-        "profileKey": "java-default-with-mojo-conventions-49307",
-        "severity": "MAJOR",
-        "inheritance": "INHERITED",
-        "ruleKey": "squid:S2293",
-        "key": "java-default-with-mojo-conventions-49307:squid:S2293"
-      }
-    },
-    {
-      "key": "AVCUXEuDdBKrKCzZ3xlQ",
-      "type": "QPROFILE",
-      "action": "ACTIVATED",
-      "createdAt": "2015-10-23T13:01:28+0200",
-      "login": "ann.campbell",
-      "details": {
-        "profileKey": "java-top-profile-without-formatting-conventions-50037",
-        "severity": "MAJOR",
-        "ruleKey": "squid:S2293",
-        "key": "java-top-profile-without-formatting-conventions-50037:squid:S2293"
-      }
-    },
-    {
-      "key": "AVCAPjakEHVBDKGwu_o1",
-      "type": "QPROFILE",
-      "action": "UPDATED",
-      "createdAt": "2015-10-19T15:16:12+0200",
-      "login": "ann.campbell",
-      "details": {
-        "profileKey": "java-for-sq-only-95381",
-        "severity": "BLOCKER",
-        "ruleKey": "squid:S2204",
-        "key": "java-for-sq-only-95381:squid:S2204"
-      }
-    },
-    {
-      "key": "AVCAPjaIEHVBDKGwu_o0",
-      "type": "QPROFILE",
-      "action": "UPDATED",
-      "createdAt": "2015-10-19T15:16:12+0200",
-      "login": "ann.campbell",
-      "details": {
-        "profileKey": "java-for-sq-java-plugin-only-92289",
-        "severity": "BLOCKER",
-        "ruleKey": "squid:S2204",
-        "key": "java-for-sq-java-plugin-only-92289:squid:S2204"
-      }
-    },
-    {
-      "key": "AVCAPjZsEHVBDKGwu_oz",
-      "type": "QPROFILE",
-      "action": "UPDATED",
-      "createdAt": "2015-10-19T15:16:12+0200",
-      "login": "ann.campbell",
-      "details": {
-        "profileKey": "java-default-with-sonarsource-conventions-27339",
-        "severity": "BLOCKER",
-        "inheritance": "INHERITED",
-        "ruleKey": "squid:S2204",
-        "key": "java-default-with-sonarsource-conventions-27339:squid:S2204"
-      }
-    },
-    {
-      "key": "AVCAPgT3EHVBDKGwu_oy",
-      "type": "QPROFILE",
-      "action": "UPDATED",
-      "createdAt": "2015-10-19T15:15:59+0200",
-      "login": "ann.campbell",
-      "details": {
-        "profileKey": "java-for-sq-only-95381",
-        "severity": "CRITICAL",
-        "ruleKey": "squid:S2204",
-        "key": "java-for-sq-only-95381:squid:S2204"
-      }
-    }
-  ]
-}
index 7f5eccc0a012b5abc7bb4b7e073e1974e7d2c348..d9504ca21a2e0e0330e31979c7448f6272d0666e 100644 (file)
@@ -67,7 +67,7 @@ public class ActivityServiceTest {
     when(system.now()).thenReturn(1_500_000_000_000L);
 
     Activity activity = new Activity();
-    activity.setType(Activity.Type.ANALYSIS_REPORT);
+    activity.setType(Activity.Type.QPROFILE);
     activity.setAction("THE_ACTION");
     activity.setMessage("THE_MSG");
     activity.setData("foo", "bar");
@@ -81,7 +81,7 @@ public class ActivityServiceTest {
       "  data_field as \"data\", " +
       "  profile_key as \"profileKey\" " +
       "from activities");
-    assertThat(dbMap).containsEntry("type", "ANALYSIS_REPORT");
+    assertThat(dbMap).containsEntry("type", "QPROFILE");
     assertThat(dbMap).containsEntry("action", "THE_ACTION");
     assertThat(dbMap).containsEntry("msg", "THE_MSG");
     assertThat(dbMap).containsEntry("profileKey", "PROFILE_KEY");
index 484b073b85dd0903c79a8a0532065498b337ef8c..0c28bb6e3ef4333191cdc540bf8af5cb5e888c7b 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.activity.index;
 
 import com.google.common.collect.ImmutableMap;
-import java.util.Arrays;
 import java.util.Date;
 import org.junit.Before;
 import org.junit.Rule;
@@ -55,19 +54,6 @@ public class ActivityIndexTest {
     assertThat(results.getDocs()).extracting("message").containsOnly("THE_MSG 1", "THE_MSG 2");
   }
 
-  @Test
-  public void search_by_type() throws Exception {
-    es.putDocuments("activities", "activity", newDoc(1, 1_500_000_000_000L), newDoc(2, 1_600_000_000_000L));
-
-    ActivityQuery query = new ActivityQuery();
-    query.setTypes(Arrays.asList("ANALYSIS_REPORT"));
-    assertThat(underTest.search(query, new SearchOptions()).getTotal()).isEqualTo(2L);
-
-    query = new ActivityQuery();
-    query.setTypes(Arrays.asList("OTHER", "TYPES"));
-    assertThat(underTest.search(query, new SearchOptions()).getTotal()).isEqualTo(0L);
-  }
-
   @Test
   public void search_by_data() throws Exception {
     es.putDocuments("activities", "activity", newDoc(1, 1_500_000_000_000L), newDoc(2, 1_600_000_000_000L));
@@ -99,7 +85,7 @@ public class ActivityIndexTest {
   ActivityDoc newDoc(int id, long date) {
     ActivityDoc doc = new ActivityDoc();
     doc.setKey("UUID" + id);
-    doc.setType(Activity.Type.ANALYSIS_REPORT.name());
+    doc.setType(Activity.Type.QPROFILE.name());
     doc.setAction("THE_ACTION " + id);
     doc.setMessage("THE_MSG " + id);
     doc.setDetails(ImmutableMap.of("foo", "bar" + id));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/activity/ws/ActivitiesWsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/activity/ws/ActivitiesWsMediumTest.java
deleted file mode 100644 (file)
index 895b3cf..0000000
+++ /dev/null
@@ -1,96 +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.server.activity.ws;
-
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.server.activity.Activity;
-import org.sonar.server.activity.ActivityService;
-import org.sonar.server.tester.ServerTester;
-import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.WsTester;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.test.JsonAssert.assertJson;
-
-public class ActivitiesWsMediumTest {
-
-  @ClassRule
-  public static ServerTester tester = new ServerTester().withStartupTasks().withEsIndexes();
-  @Rule
-  public UserSessionRule userSessionRule = UserSessionRule.forServerTester(tester);
-
-  ActivitiesWs ws;
-  ActivityService service;
-
-  @Before
-  public void setUp() {
-    tester.clearDbAndIndexes();
-    ws = tester.get(ActivitiesWs.class);
-    service = tester.get(ActivityService.class);
-  }
-
-  @Test
-  public void define() {
-    WebService.Context context = new WebService.Context();
-    ws.define(context);
-
-    WebService.Controller controller = context.controller(ActivitiesWs.ENDPOINT);
-
-    assertThat(controller).isNotNull();
-    assertThat(controller.actions()).hasSize(1);
-    assertThat(controller.action(SearchAction.SEARCH_ACTION)).isNotNull();
-  }
-
-  @Test
-  public void search() throws Exception {
-    Activity activity = new Activity();
-    activity.setType(Activity.Type.ANALYSIS_REPORT);
-    activity.setAction("THE_ACTION");
-    activity.setMessage("THE_MSG");
-    activity.setData("foo", "bar");
-    activity.setProfileKey("PROFILE_KEY");
-
-    service.save(activity);
-    WsTester.TestRequest request = tester.wsTester().newGetRequest("api/activities", "search");
-
-    String result = request.execute().outputAsString();
-    assertJson(result).isSimilarTo(
-      "{" +
-        "  \"total\": 1," +
-        "  \"p\": 1," +
-        "  \"ps\": 10," +
-        "  \"logs\": [" +
-        "    {" +
-        "      \"type\": \"ANALYSIS_REPORT\"," +
-        "      \"action\": \"THE_ACTION\"," +
-        "      \"message\": \"THE_MSG\"," +
-        "      \"details\": {" +
-        "        \"profileKey\": \"PROFILE_KEY\"," +
-        "        \"foo\": \"bar\"" +
-        "      }" +
-        "    }" +
-        "  ]" +
-        "}");
-  }
-}