+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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;
-
-import org.picocontainer.Startable;
-import org.sonar.api.ServerComponent;
-import org.sonar.server.qualityprofile.QProfileActivity;
-import org.sonar.server.qualityprofile.QProfileActivityQuery;
-import org.sonar.server.qualityprofile.QProfileService;
-import org.sonar.server.search.QueryOptions;
-import org.sonar.server.util.RubyUtils;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @deprecated in 4.4 because Ruby on Rails is deprecated too !
- */
-@Deprecated
-public class RubyActivityService implements ServerComponent, Startable {
-
- private final QProfileService service;
-
- public RubyActivityService(QProfileService service) {
- this.service = service;
- }
-
- /**
- * Used in profiles_controller.rb
- */
- public List<QProfileActivity> search(Map<String, Object> params) {
- QProfileActivityQuery query = new QProfileActivityQuery();
- List<String> profileKeys = RubyUtils.toStrings(params.get("profileKeys"));
- if (profileKeys != null) {
- query.setQprofileKeys(profileKeys);
- }
- Date since = RubyUtils.toDate(params.get("since"));
- if (since != null) {
- query.setSince(since);
- }
- Date to = RubyUtils.toDate(params.get("to"));
- if (to != null) {
- query.setTo(to);
- }
- return service.findActivities(query, new QueryOptions().setMaxLimit());
- }
-
- @Override
- public void start() {
- // used to force pico to instantiate the singleton at startup
- }
-
- @Override
- public void stop() {
- // implement startable
- }
-}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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;
+
+import org.picocontainer.Startable;
+import org.sonar.api.ServerComponent;
+import org.sonar.api.utils.Paging;
+import org.sonar.server.qualityprofile.QProfileActivity;
+import org.sonar.server.qualityprofile.QProfileActivityQuery;
+import org.sonar.server.qualityprofile.QProfileService;
+import org.sonar.server.search.QueryOptions;
+import org.sonar.server.search.Result;
+import org.sonar.server.util.RubyUtils;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @deprecated in 4.4 because Ruby on Rails is deprecated too !
+ */
+@Deprecated
+public class RubyQProfileActivityService implements ServerComponent, Startable {
+
+ private final QProfileService service;
+
+ public RubyQProfileActivityService(QProfileService service) {
+ this.service = service;
+ }
+
+ /**
+ * Used in profiles_controller.rb
+ */
+ public QProfileActivityResult search(Map<String, Object> params) {
+ QProfileActivityQuery query = new QProfileActivityQuery();
+ QueryOptions queryOptions = new QueryOptions().setMaxLimit();
+ List<String> profileKeys = RubyUtils.toStrings(params.get("profileKeys"));
+ if (profileKeys != null) {
+ query.setQprofileKeys(profileKeys);
+ }
+ Date since = RubyUtils.toDate(params.get("since"));
+ if (since != null) {
+ query.setSince(since);
+ }
+ Date to = RubyUtils.toDate(params.get("to"));
+ if (to != null) {
+ query.setTo(to);
+ }
+ Integer page = RubyUtils.toInteger(params.get("p"));
+ int pageIndex = page != null ? page : 1;
+ queryOptions.setPage(pageIndex, 50);
+
+ Result<QProfileActivity> result = service.searchActivities(query, queryOptions);
+ return new QProfileActivityResult(result.getHits(), Paging.create(queryOptions.getLimit(), pageIndex, Long.valueOf(result.getTotal()).intValue()));
+ }
+
+ @Override
+ public void start() {
+ // used to force pico to instantiate the singleton at startup
+ }
+
+ @Override
+ public void stop() {
+ // implement startable
+ }
+
+ public static class QProfileActivityResult {
+
+ private final List<QProfileActivity> activities;
+
+ private final Paging paging;
+
+ public QProfileActivityResult(List<QProfileActivity> activities, Paging paging) {
+ this.activities = activities;
+ this.paging = paging;
+ }
+
+ public List<QProfileActivity> activities() {
+ return activities;
+ }
+
+ public Paging paging() {
+ return paging;
+ }
+
+ }
+}
import org.sonar.jpa.session.DefaultDatabaseConnector;
import org.sonar.jpa.session.ThreadLocalDatabaseSessionFactory;
import org.sonar.server.activity.ActivityService;
-import org.sonar.server.activity.RubyActivityService;
+import org.sonar.server.activity.RubyQProfileActivityService;
import org.sonar.server.activity.db.ActivityDao;
import org.sonar.server.activity.index.ActivityIndex;
import org.sonar.server.activity.index.ActivityNormalizer;
pico.addSingleton(QProfileCopier.class);
pico.addSingleton(QProfileBackuper.class);
pico.addSingleton(QProfileReset.class);
- pico.addSingleton(RubyActivityService.class);
+ pico.addSingleton(RubyQProfileActivityService.class);
// rule
pico.addSingleton(AnnotationRuleParser.class);
import org.sonar.server.search.FacetValue;
import org.sonar.server.search.IndexClient;
import org.sonar.server.search.QueryOptions;
+import org.sonar.server.search.Result;
import org.sonar.server.user.UserSession;
import javax.annotation.CheckForNull;
new QueryOptions().setLimit(0)).getTotal();
}
- public List<QProfileActivity> findActivities(QProfileActivityQuery query, QueryOptions options) {
- List<QProfileActivity> results = Lists.newArrayList();
+ public Result<QProfileActivity> searchActivities(QProfileActivityQuery query, QueryOptions options) {
DbSession session = db.openSession(false);
try {
OrFilterBuilder activityFilter = FilterBuilders.orFilter();
}
SearchResponse response = index.get(ActivityIndex.class).search(query, options, activityFilter);
+ Result<QProfileActivity> result = new Result<QProfileActivity>(response);
for (SearchHit hit : response.getHits().getHits()) {
QProfileActivity profileActivity = new QProfileActivity(hit.getSource());
RuleDto ruleDto = db.ruleDao().getNullableByKey(session, profileActivity.ruleKey());
UserDto user = db.userDao().selectActiveUserByLogin(profileActivity.login(), session);
profileActivity.authorName(user != null ? user.getName() : null);
- results.add(profileActivity);
+ result.getHits().add(profileActivity);
}
- return results;
+ return result;
} finally {
session.close();
}
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
public class Result<K> {
private final String scrollId;
private final BaseIndex<K, ?, ?> index;
- public Result(BaseIndex<K, ?, ?> index, SearchResponse response) {
+ public Result(SearchResponse response) {
+ this(null, response);
+ }
+
+ public Result(@Nullable BaseIndex<K, ?, ?> index, SearchResponse response) {
this.index = index;
this.scrollId = response.getScrollId();
this.facets = LinkedListMultimap.create();
this.total = (int) response.getHits().totalHits();
this.timeInMillis = response.getTookInMillis();
this.hits = new ArrayList<K>();
- for (SearchHit hit : response.getHits()) {
- this.hits.add(index.toDoc(hit.getSource()));
+ if (index != null) {
+ for (SearchHit hit : response.getHits()) {
+ this.hits.add(index.toDoc(hit.getSource()));
+ }
}
if (response.getAggregations() != null) {
for (Map.Entry<String, Aggregation> facet : response.getAggregations().asMap().entrySet()) {
require_parameters 'key'
@profile = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).getByKey(params[:key])
- search = {'profileKeys' => @profile.key().to_s, 'since' => params[:since], 'to' => params[:to]}
- @changes = Internal.component(Java::OrgSonarServerActivity::RubyActivityService.java_class).search(search)
+ search = {'profileKeys' => @profile.key().to_s, 'since' => params[:since], 'to' => params[:to], 'p' => params[:p]}
+ result = Internal.component(Java::OrgSonarServerActivity::RubyQProfileActivityService.java_class).search(search)
+ @changes = result.activities
+ @paging = result.paging
set_profile_breadcrumbs
end
<%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'changelog'} %>
<div class="tabs-panel marginbottom10">
+ <form class="marginbottom10" method="get" action="<%= ApplicationController.root_context %>/profiles/changelog">
+ <input name="key" type="hidden" value="<%= @profile.key() %>"/>
+ <%= message('quality_profiles.changelog_from') -%>
+ <input name="since" type="text" value="<%= params['since'] %>" placeholder="1970-01-31"/>
+ <%= message('to').downcase -%>
+ <input name="to" type="text" value="<%= params['to'] %>" placeholder="1970-01-31"/>
+ <input type="submit" value="<%= h message('search_verb') -%>" id="submit"/>
+ </form>
+
<% if @changes.empty? %>
<%= message('quality_profiles.changelog.empty') -%>
<% else %>
- <form class="marginbottom10" method="get" action="<%= ApplicationController.root_context %>/profiles/changelog">
- <input name="key" type="hidden" value="<%= @profile.key() %>"/>
- <%= message('quality_profiles.changelog_from') -%>
- <input name="since" type="text" value="<%= params['since'] %>" placeholder="1970-01-31"/>
- <%= message('to').downcase -%>
- <input name="to" type="text" value="<%= params['to'] %>" placeholder="1970-01-31"/>
- <input type="submit" value="<%= h message('load_verb') -%>" id="submit"/>
- </form>
<table id="profile-changelog" class="data width100">
<thead>
<th><%= message('parameters') -%></th>
</tr>
</thead>
- <%
- @changes.each do |change|
- %>
- <tr class="<%= cycle('even', 'odd') -%>">
+ <tbody>
<%
- action = change.action()
- action_message = message('quality_profiles.changelog.' + action.downcase) if action
- author = change.authorName() ? change.authorName() : change.login() ? !change.login().emtpy? : 'System'
- rule = change.ruleName() ? change.ruleName() : change.ruleKey()
+ @changes.each do |change|
%>
- <td valign="top" width="1%" nowrap><%= Internal.i18n.formatDateTime(change.time()) -%></td>
- <td valign="top" width="1%" nowrap><%= author %></td>
- <td valign="top" width="1%" nowrap><%= action_message %></td>
- <td valign="top"><%= rule %></td>
- <td valign="top">
- <% if change.severity() %>
- <%= message('quality_profiles.severity_set_to_x', :params => ["<i class=\"icon-severity-#{change.severity().downcase}\"></i>", change.severity()]) -%>
- <br/>
- <% end %>
- <% change.parameters().each do |param_key, param_value| %>
- <% unless param_value.empty? %>
- <%= message('quality_profiles.parameter_set_to_x', :params => [param_key, param_value]) -%>
- <% else %>
- <%= message('quality_profiles.changelog.parameter_reset_to_default_value_x', :params => [param_key]) -%>
+ <tr class="<%= cycle('even', 'odd') -%>">
+ <%
+ action = change.action()
+ action_message = message('quality_profiles.changelog.' + action.downcase) if action
+ author = change.authorName() ? change.authorName() : change.login() ? !change.login().emtpy? : 'System'
+ rule = change.ruleName() ? change.ruleName() : change.ruleKey()
+ %>
+ <td valign="top" width="1%" nowrap><%= Internal.i18n.formatDateTime(change.time()) -%></td>
+ <td valign="top" width="1%" nowrap><%= author %></td>
+ <td valign="top" width="1%" nowrap><%= action_message %></td>
+ <td valign="top"><%= rule %></td>
+ <td valign="top">
+ <% if change.severity() %>
+ <%= message('quality_profiles.severity_set_to_x', :params => ["<i class=\"icon-severity-#{change.severity().downcase}\"></i>", change.severity()]) -%>
+ <br/>
+ <% end %>
+ <% change.parameters().each do |param_key, param_value| %>
+ <% unless param_value.empty? %>
+ <%= message('quality_profiles.parameter_set_to_x', :params => [param_key, param_value]) -%>
+ <% else %>
+ <%= message('quality_profiles.changelog.parameter_reset_to_default_value_x', :params => [param_key]) -%>
+ <% end %>
+ <br/>
<% end %>
- <br/>
- <% end %>
- </td>
- </tr>
- <% end %>
+ </td>
+ </tr>
+ <% end %>
+ </tbody>
+ <%= paginate_java(@paging, :colspan => 5, :include_loading_icon => true) { |label, page_id|
+ link_to(label, params.merge({:p => page_id}), :style => 'text-decoration:underline')
+ }
+ %>
</table>
<% end %>
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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;
-
-import com.google.common.collect.ImmutableMap;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.sonar.api.utils.DateUtils;
-import org.sonar.core.activity.Activity;
-import org.sonar.server.qualityprofile.QProfileActivityQuery;
-import org.sonar.server.qualityprofile.QProfileService;
-import org.sonar.server.search.QueryOptions;
-
-import java.util.Date;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Mockito.verify;
-
-@RunWith(MockitoJUnitRunner.class)
-public class RubyActivityServiceTest {
-
- @Mock
- QProfileService service;
-
- @Captor
- ArgumentCaptor<QProfileActivityQuery> activityArgumentCaptor;
-
- @Captor
- ArgumentCaptor<QueryOptions> queryOptionsArgumentCaptor;
-
- RubyActivityService rubyActivityService;
-
- @Before
- public void setUp() throws Exception {
- rubyActivityService = new RubyActivityService(service);
- }
-
- @Test
- public void search() throws Exception {
- Date since = DateUtils.parseDate("2014-05-19");
- Date to = DateUtils.parseDate("2014-06-19");
- rubyActivityService.search(ImmutableMap.<String, Object>of("profileKeys", "PROFILE_KEY", "since", since, "to", to));
-
- verify(service).findActivities(activityArgumentCaptor.capture(), queryOptionsArgumentCaptor.capture());
-
- assertThat(queryOptionsArgumentCaptor.getValue().getLimit()).isEqualTo(QueryOptions.MAX_LIMIT);
-
- assertThat(activityArgumentCaptor.getValue().getQprofileKeys()).containsOnly("PROFILE_KEY");
- assertThat(activityArgumentCaptor.getValue().getTypes()).containsOnly(Activity.Type.QPROFILE);
- assertThat(activityArgumentCaptor.getValue().getSince()).isEqualTo(since);
- assertThat(activityArgumentCaptor.getValue().getTo()).isEqualTo(to);
- }
-
- @Test
- public void search_with_empty_fields() throws Exception {
- rubyActivityService.search(ImmutableMap.<String, Object>of());
-
- verify(service).findActivities(activityArgumentCaptor.capture(), queryOptionsArgumentCaptor.capture());
-
- assertThat(queryOptionsArgumentCaptor.getValue().getLimit()).isEqualTo(QueryOptions.MAX_LIMIT);
-
- assertThat(activityArgumentCaptor.getValue().getQprofileKeys()).isEmpty();
- assertThat(activityArgumentCaptor.getValue().getSince()).isNull();
- assertThat(activityArgumentCaptor.getValue().getTo()).isNull();
- }
-}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.sonar.api.utils.DateUtils;
+import org.sonar.core.activity.Activity;
+import org.sonar.server.qualityprofile.QProfileActivity;
+import org.sonar.server.qualityprofile.QProfileActivityQuery;
+import org.sonar.server.qualityprofile.QProfileService;
+import org.sonar.server.search.QueryOptions;
+import org.sonar.server.search.Result;
+
+import java.util.Date;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+
+@RunWith(MockitoJUnitRunner.class)
+public class RubyQProfileActivityServiceTest {
+
+ @Mock
+ QProfileService service;
+
+ @Captor
+ ArgumentCaptor<QProfileActivityQuery> activityArgumentCaptor;
+
+ @Captor
+ ArgumentCaptor<QueryOptions> queryOptionsArgumentCaptor;
+
+ RubyQProfileActivityService rubyQProfileActivityService;
+
+ @Before
+ public void setUp() throws Exception {
+ rubyQProfileActivityService = new RubyQProfileActivityService(service);
+ }
+
+ @Test
+ public void search() throws Exception {
+ Date since = DateUtils.parseDate("2014-05-19");
+ Date to = DateUtils.parseDate("2014-06-19");
+
+ Result<QProfileActivity> result = mock(Result.class);
+ when(result.getHits()).thenReturn(Lists.<QProfileActivity>newArrayList());
+ when(result.getTotal()).thenReturn(10L);
+ when(service.searchActivities(any(QProfileActivityQuery.class), any(QueryOptions.class))).thenReturn(result);
+
+ rubyQProfileActivityService.search(ImmutableMap.<String, Object>of("profileKeys", "PROFILE_KEY", "since", since, "to", to));
+
+ verify(service).searchActivities(activityArgumentCaptor.capture(), queryOptionsArgumentCaptor.capture());
+
+ assertThat(queryOptionsArgumentCaptor.getValue().getLimit()).isEqualTo(50);
+
+ assertThat(activityArgumentCaptor.getValue().getQprofileKeys()).containsOnly("PROFILE_KEY");
+ assertThat(activityArgumentCaptor.getValue().getTypes()).containsOnly(Activity.Type.QPROFILE);
+ assertThat(activityArgumentCaptor.getValue().getSince()).isEqualTo(since);
+ assertThat(activityArgumentCaptor.getValue().getTo()).isEqualTo(to);
+ }
+
+ @Test
+ public void search_with_empty_fields() throws Exception {
+ Result<QProfileActivity> result = mock(Result.class);
+ when(result.getHits()).thenReturn(Lists.<QProfileActivity>newArrayList());
+ when(result.getTotal()).thenReturn(10L);
+ when(service.searchActivities(any(QProfileActivityQuery.class), any(QueryOptions.class))).thenReturn(result);
+
+ rubyQProfileActivityService.search(ImmutableMap.<String, Object>of());
+
+ verify(service).searchActivities(activityArgumentCaptor.capture(), queryOptionsArgumentCaptor.capture());
+
+ assertThat(queryOptionsArgumentCaptor.getValue().getLimit()).isEqualTo(50);
+
+ assertThat(activityArgumentCaptor.getValue().getQprofileKeys()).isEmpty();
+ assertThat(activityArgumentCaptor.getValue().getSince()).isNull();
+ assertThat(activityArgumentCaptor.getValue().getTo()).isNull();
+ }
+}
import org.sonar.server.rule.RuleTesting;
import org.sonar.server.search.FacetValue;
import org.sonar.server.search.QueryOptions;
+import org.sonar.server.search.Result;
import org.sonar.server.tester.ServerTester;
import org.sonar.server.user.MockUserSession;
);
dbSession.commit();
- List<QProfileActivity> activities = service.findActivities(new QProfileActivityQuery(), new QueryOptions());
- assertThat(activities).hasSize(1);
+ Result<QProfileActivity> activities = service.searchActivities(new QProfileActivityQuery(), new QueryOptions());
+ assertThat(activities.getHits()).hasSize(1);
- QProfileActivity activity = activities.get(0);
+ QProfileActivity activity = activities.getHits().get(0);
assertThat(activity.type()).isEqualTo(Activity.Type.QPROFILE);
assertThat(activity.action()).isEqualTo(ActiveRuleChange.Type.ACTIVATED.name());
assertThat(activity.ruleKey()).isEqualTo(RuleTesting.XOO_X1);
);
dbSession.commit();
- List<QProfileActivity> activities = service.findActivities(new QProfileActivityQuery(), new QueryOptions());
- assertThat(activities).hasSize(1);
+ Result<QProfileActivity> activities = service.searchActivities(new QProfileActivityQuery(), new QueryOptions());
+ assertThat(activities.getHits()).hasSize(1);
- QProfileActivity activity = activities.get(0);
+ QProfileActivity activity = activities.getHits().get(0);
assertThat(activity.severity()).isNull();
assertThat(activity.parameters()).hasSize(1);
assertThat(activity.parameters().get("max")).isEqualTo("10");
);
dbSession.commit();
- List<QProfileActivity> activities = service.findActivities(new QProfileActivityQuery(), new QueryOptions());
- assertThat(activities).hasSize(1);
+ Result<QProfileActivity> activities = service.searchActivities(new QProfileActivityQuery(), new QueryOptions());
+ assertThat(activities.getHits()).hasSize(1);
- QProfileActivity activity = activities.get(0);
+ QProfileActivity activity = activities.getHits().get(0);
assertThat(activity.login()).isEqualTo("david");
assertThat(activity.authorName()).isNull();
}
);
dbSession.commit();
- List<QProfileActivity> activities = service.findActivities(new QProfileActivityQuery(), new QueryOptions());
- assertThat(activities).hasSize(1);
+ Result<QProfileActivity> activities = service.searchActivities(new QProfileActivityQuery(), new QueryOptions());
+ assertThat(activities.getHits()).hasSize(1);
- QProfileActivity activity = activities.get(0);
+ QProfileActivity activity = activities.getHits().get(0);
assertThat(activity.ruleKey()).isEqualTo(ruleKey);
assertThat(activity.ruleName()).isNull();
}
dbSession.commit();
// 0. Base case verify 2 activities in index
- assertThat(service.findActivities(new QProfileActivityQuery(), new QueryOptions()))
+ assertThat(service.searchActivities(new QProfileActivityQuery(), new QueryOptions()).getHits())
.hasSize(2);
// 1. filter by QProfile
- List<QProfileActivity> result = service.findActivities(new QProfileActivityQuery()
- .setQprofileKeys(ImmutableSet.of(XOO_P1_KEY)), new QueryOptions());
+ List<QProfileActivity> result = service.searchActivities(new QProfileActivityQuery()
+ .setQprofileKeys(ImmutableSet.of(XOO_P1_KEY)), new QueryOptions()).getHits();
assertThat(result).hasSize(1);
// 1. filter by QProfiles
- assertThat(service.findActivities(new QProfileActivityQuery()
+ assertThat(service.searchActivities(new QProfileActivityQuery()
.setQprofileKeys(ImmutableSet.of(XOO_P1_KEY, XOO_P2_KEY))
- , new QueryOptions())).hasSize(2);
+ , new QueryOptions()).getHits()).hasSize(2);
}
@Test
dbSession.commit();
// 0. Base case verify 2 activities in index
- assertThat(service.findActivities(new QProfileActivityQuery(), new QueryOptions()))
+ assertThat(service.searchActivities(new QProfileActivityQuery(), new QueryOptions()).getHits())
.hasSize(2);
// 1. filter by QProfile
- List<QProfileActivity> result = service.findActivities(new QProfileActivityQuery()
- .setQprofileKeys(ImmutableSet.of("java-default")), new QueryOptions());
+ List<QProfileActivity> result = service.searchActivities(new QProfileActivityQuery()
+ .setQprofileKeys(ImmutableSet.of("java-default")), new QueryOptions()).getHits();
assertThat(result).hasSize(1);
// 1. filter by QProfiles
- assertThat(service.findActivities(new QProfileActivityQuery()
+ assertThat(service.searchActivities(new QProfileActivityQuery()
.setQprofileKeys(ImmutableSet.of("java-default", "java-toto"))
- , new QueryOptions())).hasSize(2);
+ , new QueryOptions()).getHits()).hasSize(2);
}
}