]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7287 Rename FavoriteService to FavoriteUpdater
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Fri, 16 Dec 2016 10:09:21 +0000 (11:09 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Mon, 19 Dec 2016 09:12:53 +0000 (10:12 +0100)
12 files changed:
server/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java
server/sonar-server/src/main/java/org/sonar/server/computation/queue/ReportSubmitter.java
server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteModule.java
server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteService.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteUpdater.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/favorite/ws/AddAction.java
server/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/queue/ReportSubmitterTest.java
server/sonar-server/src/test/java/org/sonar/server/favorite/FavoriteServiceTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/favorite/FavoriteUpdaterTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/favorite/ws/AddActionTest.java
server/sonar-server/src/test/java/org/sonar/server/favorite/ws/FavoritesWsTest.java

index 3e0531b660855ee395c3e1847643e00769673cd0..19325c6d9dc1fdc3860cb61601f7d853af5d60c1 100644 (file)
@@ -32,7 +32,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.ResourceDao;
 import org.sonar.db.component.ResourceDto;
-import org.sonar.server.favorite.FavoriteService;
+import org.sonar.server.favorite.FavoriteUpdater;
 import org.sonar.server.permission.PermissionTemplateService;
 import org.sonar.server.util.RubyUtils;
 
@@ -42,15 +42,15 @@ public class DefaultRubyComponentService implements RubyComponentService {
   private final ResourceDao resourceDao;
   private final ComponentService componentService;
   private final PermissionTemplateService permissionTemplateService;
-  private final FavoriteService favoriteService;
+  private final FavoriteUpdater favoriteUpdater;
 
   public DefaultRubyComponentService(DbClient dbClient, ResourceDao resourceDao, ComponentService componentService, PermissionTemplateService permissionTemplateService,
-    FavoriteService favoriteService) {
+    FavoriteUpdater favoriteUpdater) {
     this.dbClient = dbClient;
     this.resourceDao = resourceDao;
     this.componentService = componentService;
     this.permissionTemplateService = permissionTemplateService;
-    this.favoriteService = favoriteService;
+    this.favoriteUpdater = favoriteUpdater;
   }
 
   @Override
@@ -88,7 +88,7 @@ public class DefaultRubyComponentService implements RubyComponentService {
     permissionTemplateService.applyDefaultPermissionTemplate(dbSession, provisionedComponent.getKey());
     if (Qualifiers.PROJECT.equals(provisionedComponent.qualifier())
       && permissionTemplateService.hasDefaultTemplateWithPermissionOnProjectCreator(dbSession, provisionedComponent)) {
-      favoriteService.put(dbSession, provisionedComponent.getId());
+      favoriteUpdater.put(dbSession, provisionedComponent.getId());
       dbSession.commit();
     }
 
index 18b2990583e162e5f69569ef676d028dc8a19dae..4c28e03bf0dbc29101174bbe9f0b91719e86593b 100644 (file)
@@ -34,7 +34,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.ce.CeTaskTypes;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.server.component.ComponentService;
-import org.sonar.server.favorite.FavoriteService;
+import org.sonar.server.favorite.FavoriteUpdater;
 import org.sonar.server.component.NewComponent;
 import org.sonar.server.permission.PermissionTemplateService;
 import org.sonar.server.user.UserSession;
@@ -50,16 +50,16 @@ public class ReportSubmitter {
   private final ComponentService componentService;
   private final PermissionTemplateService permissionTemplateService;
   private final DbClient dbClient;
-  private final FavoriteService favoriteService;
+  private final FavoriteUpdater favoriteUpdater;
 
   public ReportSubmitter(CeQueue queue, UserSession userSession,
-    ComponentService componentService, PermissionTemplateService permissionTemplateService, DbClient dbClient, FavoriteService favoriteService) {
+    ComponentService componentService, PermissionTemplateService permissionTemplateService, DbClient dbClient, FavoriteUpdater favoriteUpdater) {
     this.queue = queue;
     this.userSession = userSession;
     this.componentService = componentService;
     this.permissionTemplateService = permissionTemplateService;
     this.dbClient = dbClient;
-    this.favoriteService = favoriteService;
+    this.favoriteUpdater = favoriteUpdater;
   }
 
   public CeTask submit(String projectKey, @Nullable String projectBranch, @Nullable String projectName, InputStream reportInput) {
@@ -88,7 +88,7 @@ public class ReportSubmitter {
     // "provisioning" permission is check in ComponentService
     ComponentDto project = componentService.create(dbSession, newProject);
     if (permissionTemplateService.hasDefaultTemplateWithPermissionOnProjectCreator(dbSession, project)) {
-      favoriteService.put(dbSession, project.getId());
+      favoriteUpdater.put(dbSession, project.getId());
       dbSession.commit();
     }
 
index e6e4ab613c0c8ed213179a5024a2416f8e727d3d..7107b6df851a8bc4e022ac74163abc33cbae4843 100644 (file)
@@ -29,7 +29,7 @@ public class FavoriteModule extends Module {
   @Override
   protected void configureModule() {
     add(
-      FavoriteService.class,
+      FavoriteUpdater.class,
       FavoritesWs.class,
       AddAction.class);
   }
diff --git a/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteService.java b/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteService.java
deleted file mode 100644 (file)
index 9ab4d10..0000000
+++ /dev/null
@@ -1,52 +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.favorite;
-
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.property.PropertyDto;
-import org.sonar.server.user.UserSession;
-
-public class FavoriteService {
-  private static final String PROP_FAVORITE_KEY = "favourite";
-
-  private final DbClient dbClient;
-  private final UserSession userSession;
-
-  public FavoriteService(DbClient dbClient, UserSession userSession) {
-    this.dbClient = dbClient;
-    this.userSession = userSession;
-  }
-
-  /**
-   * Set favorite to the logged in user. If no user is logged, no action is done
-   */
-  public void put(DbSession dbSession, long componentDbId) {
-    if (!userSession.isLoggedIn()) {
-      return;
-    }
-
-    dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto()
-      .setKey(PROP_FAVORITE_KEY)
-      .setResourceId(componentDbId)
-      .setUserId(Long.valueOf(userSession.getUserId())));
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteUpdater.java
new file mode 100644 (file)
index 0000000..7ae2a9c
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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.favorite;
+
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+import org.sonar.db.property.PropertyDto;
+import org.sonar.server.user.UserSession;
+
+public class FavoriteUpdater {
+  private static final String PROP_FAVORITE_KEY = "favourite";
+
+  private final DbClient dbClient;
+  private final UserSession userSession;
+
+  public FavoriteUpdater(DbClient dbClient, UserSession userSession) {
+    this.dbClient = dbClient;
+    this.userSession = userSession;
+  }
+
+  /**
+   * Set favorite to the logged in user. If no user is logged, no action is done
+   */
+  public void put(DbSession dbSession, long componentDbId) {
+    if (!userSession.isLoggedIn()) {
+      return;
+    }
+
+    dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto()
+      .setKey(PROP_FAVORITE_KEY)
+      .setResourceId(componentDbId)
+      .setUserId(Long.valueOf(userSession.getUserId())));
+  }
+}
index ea7280b6ddb27fccac458371218601f55eefb87a..031f7e69d37ac30dabcd72acde599809d186e465 100644 (file)
@@ -29,7 +29,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.server.component.ComponentFinder;
-import org.sonar.server.favorite.FavoriteService;
+import org.sonar.server.favorite.FavoriteUpdater;
 import org.sonar.server.user.UserSession;
 import org.sonar.server.ws.KeyExamples;
 
@@ -38,13 +38,13 @@ import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.PARAM_COMPO
 public class AddAction implements FavoritesWsAction {
   private final UserSession userSession;
   private final DbClient dbClient;
-  private final FavoriteService favoriteService;
+  private final FavoriteUpdater favoriteUpdater;
   private final ComponentFinder componentFinder;
 
-  public AddAction(UserSession userSession, DbClient dbClient, FavoriteService favoriteService, ComponentFinder componentFinder) {
+  public AddAction(UserSession userSession, DbClient dbClient, FavoriteUpdater favoriteUpdater, ComponentFinder componentFinder) {
     this.userSession = userSession;
     this.dbClient = dbClient;
-    this.favoriteService = favoriteService;
+    this.favoriteUpdater = favoriteUpdater;
     this.componentFinder = componentFinder;
   }
 
@@ -76,7 +76,7 @@ public class AddAction implements FavoritesWsAction {
         userSession
           .checkLoggedIn()
           .checkComponentUuidPermission(UserRole.USER, componentDto.uuid());
-        favoriteService.put(dbSession, componentDto.getId());
+        favoriteUpdater.put(dbSession, componentDto.getId());
         dbSession.commit();
       }
     };
index b0f5fc8df2c57e1441da14d3ebb6ef86e6383f85..16c8485c2bff12f872c16f5ea37321842d43c536 100644 (file)
@@ -37,7 +37,7 @@ import org.sonar.server.component.es.ProjectMeasuresIndexDefinition;
 import org.sonar.server.component.es.ProjectMeasuresIndexer;
 import org.sonar.server.es.EsTester;
 import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.favorite.FavoriteService;
+import org.sonar.server.favorite.FavoriteUpdater;
 import org.sonar.server.i18n.I18nRule;
 import org.sonar.server.permission.PermissionTemplateService;
 import org.sonar.server.tester.UserSessionRule;
@@ -74,11 +74,11 @@ public class DefaultRubyComponentServiceTest {
   private ComponentService componentService = new ComponentService(dbClient, i18n, userSession, system2, new ComponentFinder(dbClient),
     new ProjectMeasuresIndexer(system2, dbClient, es.client()));
   private PermissionTemplateService permissionTemplateService = mock(PermissionTemplateService.class);
-  private FavoriteService favoriteService = mock(FavoriteService.class);
+  private FavoriteUpdater favoriteUpdater = mock(FavoriteUpdater.class);
 
   ComponentDbTester componentDb = new ComponentDbTester(db);
 
-  DefaultRubyComponentService underTest = new DefaultRubyComponentService(dbClient, resourceDao, componentService, permissionTemplateService, favoriteService);
+  DefaultRubyComponentService underTest = new DefaultRubyComponentService(dbClient, resourceDao, componentService, permissionTemplateService, favoriteUpdater);
 
   @Test
   public void find_by_key() {
@@ -117,7 +117,7 @@ public class DefaultRubyComponentServiceTest {
     assertThat(project.qualifier()).isEqualTo(qualifier);
     assertThat(project.getId()).isEqualTo(result);
     verify(permissionTemplateService).applyDefaultPermissionTemplate(any(DbSession.class), eq(componentKey));
-    verify(favoriteService).put(any(DbSession.class), eq(project.getId()));
+    verify(favoriteUpdater).put(any(DbSession.class), eq(project.getId()));
   }
 
   @Test(expected = BadRequestException.class)
index 9c8f148c988fbd89c68bca7272433b63e8560f4c..687d267c9e062798ab0aa38113574265a3828349 100644 (file)
@@ -36,7 +36,7 @@ import org.sonar.db.DbTester;
 import org.sonar.db.ce.CeTaskTypes;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.server.component.ComponentService;
-import org.sonar.server.favorite.FavoriteService;
+import org.sonar.server.favorite.FavoriteUpdater;
 import org.sonar.server.component.NewComponent;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.permission.PermissionTemplateService;
@@ -74,9 +74,9 @@ public class ReportSubmitterTest {
   private CeQueue queue = mock(CeQueueImpl.class);
   private ComponentService componentService = mock(ComponentService.class);
   private PermissionTemplateService permissionTemplateService = mock(PermissionTemplateService.class);
-  private FavoriteService favoriteService = mock(FavoriteService.class);
+  private FavoriteUpdater favoriteUpdater = mock(FavoriteUpdater.class);
 
-  private ReportSubmitter underTest = new ReportSubmitter(queue, userSession, componentService, permissionTemplateService, db.getDbClient(), favoriteService);
+  private ReportSubmitter underTest = new ReportSubmitter(queue, userSession, componentService, permissionTemplateService, db.getDbClient(), favoriteUpdater);
 
   @Test
   public void submit_a_report_on_existing_project() {
@@ -89,7 +89,7 @@ public class ReportSubmitterTest {
 
     verifyReportIsPersisted(TASK_UUID);
     verifyZeroInteractions(permissionTemplateService);
-    verifyZeroInteractions(favoriteService);
+    verifyZeroInteractions(favoriteUpdater);
     verify(queue).submit(argThat(new TypeSafeMatcher<CeTaskSubmit>() {
       @Override
       protected boolean matchesSafely(CeTaskSubmit submit) {
@@ -119,7 +119,7 @@ public class ReportSubmitterTest {
 
     verifyReportIsPersisted(TASK_UUID);
     verify(permissionTemplateService).applyDefault(any(DbSession.class), eq(createdProject), anyLong());
-    verify(favoriteService).put(any(DbSession.class), eq(createdProject.getId()));
+    verify(favoriteUpdater).put(any(DbSession.class), eq(createdProject.getId()));
     verify(queue).submit(argThat(new TypeSafeMatcher<CeTaskSubmit>() {
       @Override
       protected boolean matchesSafely(CeTaskSubmit submit) {
@@ -147,7 +147,7 @@ public class ReportSubmitterTest {
 
     underTest.submit(PROJECT_KEY, null, PROJECT_NAME, IOUtils.toInputStream("{binary}"));
 
-    verifyZeroInteractions(favoriteService);
+    verifyZeroInteractions(favoriteUpdater);
   }
 
   @Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/favorite/FavoriteServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/favorite/FavoriteServiceTest.java
deleted file mode 100644 (file)
index 6fce121..0000000
+++ /dev/null
@@ -1,89 +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.favorite;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.DbTester;
-import org.sonar.db.property.PropertyQuery;
-import org.sonar.server.tester.UserSessionRule;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class FavoriteServiceTest {
-  private static final long COMPONENT_ID = 23L;
-  private static final long USER_ID = 42L;
-
-  @Rule
-  public UserSessionRule userSession = UserSessionRule.standalone().login().setUserId((int) USER_ID);
-
-  @Rule
-  public DbTester db = DbTester.create(System2.INSTANCE);
-  private DbClient dbClient = db.getDbClient();
-  private DbSession dbSession = db.getSession();
-
-  private FavoriteService underTest = new FavoriteService(dbClient, userSession);
-
-  @Test
-  public void put_favorite() {
-    assertNoFavorite();
-
-    underTest.put(dbSession, COMPONENT_ID);
-
-    assertFavorite();
-  }
-
-  @Test
-  public void do_nothing_when_not_logged_in() {
-    userSession.anonymous();
-
-    underTest.put(dbSession, COMPONENT_ID);
-
-    assertNoFavorite();
-  }
-
-  @Test
-  public void put_existing_favorite() {
-    underTest.put(dbSession, COMPONENT_ID);
-    assertFavorite();
-
-    underTest.put(dbSession, COMPONENT_ID);
-
-    assertFavorite();
-  }
-
-  private void assertFavorite() {
-    assertThat(dbClient.propertiesDao().selectByQuery(PropertyQuery.builder()
-      .setUserId((int) USER_ID)
-      .setComponentId(COMPONENT_ID)
-      .build(), dbSession)).hasSize(1);
-  }
-
-  private void assertNoFavorite() {
-    assertThat(dbClient.propertiesDao().selectByQuery(PropertyQuery.builder()
-      .setUserId((int) USER_ID)
-      .setComponentId(COMPONENT_ID)
-      .build(), dbSession)).isEmpty();
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/favorite/FavoriteUpdaterTest.java b/server/sonar-server/src/test/java/org/sonar/server/favorite/FavoriteUpdaterTest.java
new file mode 100644 (file)
index 0000000..157b751
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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.favorite;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+import org.sonar.db.DbTester;
+import org.sonar.db.property.PropertyQuery;
+import org.sonar.server.tester.UserSessionRule;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class FavoriteUpdaterTest {
+  private static final long COMPONENT_ID = 23L;
+  private static final long USER_ID = 42L;
+
+  @Rule
+  public UserSessionRule userSession = UserSessionRule.standalone().login().setUserId((int) USER_ID);
+
+  @Rule
+  public DbTester db = DbTester.create(System2.INSTANCE);
+  private DbClient dbClient = db.getDbClient();
+  private DbSession dbSession = db.getSession();
+
+  private FavoriteUpdater underTest = new FavoriteUpdater(dbClient, userSession);
+
+  @Test
+  public void put_favorite() {
+    assertNoFavorite();
+
+    underTest.put(dbSession, COMPONENT_ID);
+
+    assertFavorite();
+  }
+
+  @Test
+  public void do_nothing_when_not_logged_in() {
+    userSession.anonymous();
+
+    underTest.put(dbSession, COMPONENT_ID);
+
+    assertNoFavorite();
+  }
+
+  @Test
+  public void put_existing_favorite() {
+    underTest.put(dbSession, COMPONENT_ID);
+    assertFavorite();
+
+    underTest.put(dbSession, COMPONENT_ID);
+
+    assertFavorite();
+  }
+
+  private void assertFavorite() {
+    assertThat(dbClient.propertiesDao().selectByQuery(PropertyQuery.builder()
+      .setUserId((int) USER_ID)
+      .setComponentId(COMPONENT_ID)
+      .build(), dbSession)).hasSize(1);
+  }
+
+  private void assertNoFavorite() {
+    assertThat(dbClient.propertiesDao().selectByQuery(PropertyQuery.builder()
+      .setUserId((int) USER_ID)
+      .setComponentId(COMPONENT_ID)
+      .build(), dbSession)).isEmpty();
+  }
+}
index 99d04fa81f02a4a68b53cace1965ef0409fc7059..13488c41e2e36bddb627b8eb2958d772eabe71e4 100644 (file)
@@ -34,7 +34,7 @@ import org.sonar.db.component.ComponentDto;
 import org.sonar.db.property.PropertyDto;
 import org.sonar.db.property.PropertyQuery;
 import org.sonar.server.component.ComponentFinder;
-import org.sonar.server.favorite.FavoriteService;
+import org.sonar.server.favorite.FavoriteUpdater;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.exceptions.UnauthorizedException;
@@ -64,8 +64,8 @@ public class AddActionTest {
   private DbClient dbClient = db.getDbClient();
   private DbSession dbSession = db.getSession();
 
-  private FavoriteService favoriteService = new FavoriteService(dbClient, userSession);
-  private WsActionTester ws = new WsActionTester(new AddAction(userSession, dbClient, favoriteService, new ComponentFinder(dbClient)));
+  private FavoriteUpdater favoriteUpdater = new FavoriteUpdater(dbClient, userSession);
+  private WsActionTester ws = new WsActionTester(new AddAction(userSession, dbClient, favoriteUpdater, new ComponentFinder(dbClient)));
 
   @Test
   public void add_a_project() {
index 52f9e11be24b8c983d8ad7f9cd2e500aa6ab6285..643294fb06665f32f50f4a9826614ef6ceb6aa8a 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.Test;
 import org.sonar.api.server.ws.WebService.Controller;
 import org.sonar.db.DbClient;
 import org.sonar.server.component.ComponentFinder;
-import org.sonar.server.favorite.FavoriteService;
+import org.sonar.server.favorite.FavoriteUpdater;
 import org.sonar.server.user.UserSession;
 import org.sonar.server.ws.WsTester;
 
@@ -33,7 +33,7 @@ import static org.mockito.Mockito.mock;
 
 public class FavoritesWsTest {
 
-  private final FavoritesWsAction[] actions = {new AddAction(mock(UserSession.class), mock(DbClient.class), mock(FavoriteService.class), mock(ComponentFinder.class))};
+  private final FavoritesWsAction[] actions = {new AddAction(mock(UserSession.class), mock(DbClient.class), mock(FavoriteUpdater.class), mock(ComponentFinder.class))};
   private WsTester ws = new WsTester(new FavoritesWs(actions));
 
   private Controller underTest = ws.controller("api/favorites");