aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/activity/Activity.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivitiesWs.java43
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivityMapping.java57
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java93
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/activity/ws/package-info.java23
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java7
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java1
-rw-r--r--server/sonar-server/src/main/resources/org/sonar/server/activity/ws/search-example.json144
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/activity/ActivityServiceTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexTest.java16
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/activity/ws/ActivitiesWsMediumTest.java96
12 files changed, 4 insertions, 487 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
index 56b29de5dec..8c8b06ad653 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
@@ -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
diff --git a/server/sonar-server/src/main/java/org/sonar/server/activity/Activity.java b/server/sonar-server/src/main/java/org/sonar/server/activity/Activity.java
index 3c05da730fe..94ef2824bd9 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/activity/Activity.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/activity/Activity.java
@@ -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
index 320fae11b07..00000000000
--- a/server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivitiesWs.java
+++ /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
index 67afe627da0..00000000000
--- a/server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivityMapping.java
+++ /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
index 1621adea92a..00000000000
--- a/server/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java
+++ /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
index 66aa6b09e4e..00000000000
--- a/server/sonar-server/src/main/java/org/sonar/server/activity/ws/package-info.java
+++ /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;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
index ef0e64a9137..015abc77720 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
@@ -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,
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
index ff3c7eb23f5..e5f3911c31d 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
@@ -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
index 2a67014ef4c..00000000000
--- a/server/sonar-server/src/main/resources/org/sonar/server/activity/ws/search-example.json
+++ /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"
- }
- }
- ]
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/activity/ActivityServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/activity/ActivityServiceTest.java
index 7f5eccc0a01..d9504ca21a2 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/activity/ActivityServiceTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/activity/ActivityServiceTest.java
@@ -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");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexTest.java
index 484b073b85d..0c28bb6e3ef 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexTest.java
@@ -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;
@@ -56,19 +55,6 @@ public class ActivityIndexTest {
}
@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
index 895b3cf2331..00000000000
--- a/server/sonar-server/src/test/java/org/sonar/server/activity/ws/ActivitiesWsMediumTest.java
+++ /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\"" +
- " }" +
- " }" +
- " ]" +
- "}");
- }
-}