diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-12-16 11:08:29 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-12-19 10:12:52 +0100 |
commit | b55c11eff742dd35e273e1a3fcc79e51a89a90e2 (patch) | |
tree | 85060667ebc4b157cafac8a11b40661af4e370b4 | |
parent | 3a3bf3073419bc6c21a67965a9f8259dbb164fc6 (diff) | |
download | sonarqube-b55c11eff742dd35e273e1a3fcc79e51a89a90e2.tar.gz sonarqube-b55c11eff742dd35e273e1a3fcc79e51a89a90e2.zip |
SONAR-7287 Move FavoriteService to favorite package
14 files changed, 58 insertions, 16 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java b/server/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java index 736c3dbb917..3e0531b6608 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java @@ -32,6 +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.permission.PermissionTemplateService; import org.sonar.server.util.RubyUtils; diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/queue/ReportSubmitter.java b/server/sonar-server/src/main/java/org/sonar/server/computation/queue/ReportSubmitter.java index 64e16746c8a..18b2990583e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/queue/ReportSubmitter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/queue/ReportSubmitter.java @@ -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.component.FavoriteService; +import org.sonar.server.favorite.FavoriteService; import org.sonar.server.component.NewComponent; import org.sonar.server.permission.PermissionTemplateService; import org.sonar.server.user.UserSession; diff --git a/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteModule.java b/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteModule.java index 6ef9eee9ada..e6e4ab613c0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteModule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteModule.java @@ -21,14 +21,17 @@ package org.sonar.server.favorite; import org.sonar.core.platform.Module; +import org.sonar.server.favorite.ws.AddAction; +import org.sonar.server.favorite.ws.FavoritesWs; public class FavoriteModule extends Module { @Override protected void configureModule() { add( - // TODO - ); + FavoriteService.class, + FavoritesWs.class, + AddAction.class); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/FavoriteService.java b/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteService.java index bf1045f4eb0..9ab4d10d5d7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/FavoriteService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteService.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.component; +package org.sonar.server.favorite; import org.sonar.db.DbClient; import org.sonar.db.DbSession; diff --git a/server/sonar-server/src/main/java/org/sonar/server/favorite/ws/AddAction.java b/server/sonar-server/src/main/java/org/sonar/server/favorite/ws/AddAction.java index fe288687d39..ea7280b6ddb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/favorite/ws/AddAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/favorite/ws/AddAction.java @@ -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.component.FavoriteService; +import org.sonar.server.favorite.FavoriteService; import org.sonar.server.user.UserSession; import org.sonar.server.ws.KeyExamples; 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 f7a71af88bb..693f6f5976c 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 @@ -41,7 +41,6 @@ import org.sonar.server.component.ComponentFinder; import org.sonar.server.component.ComponentService; import org.sonar.server.component.DefaultComponentFinder; import org.sonar.server.component.DefaultRubyComponentService; -import org.sonar.server.component.FavoriteService; import org.sonar.server.component.es.ProjectsEsModule; import org.sonar.server.component.ws.ComponentsWsModule; import org.sonar.server.config.ws.PropertiesWs; @@ -57,6 +56,7 @@ import org.sonar.server.email.ws.EmailsWsModule; import org.sonar.server.es.IndexCreator; import org.sonar.server.es.IndexDefinitions; import org.sonar.server.event.NewAlerts; +import org.sonar.server.favorite.FavoriteModule; import org.sonar.server.issue.AddTagsAction; import org.sonar.server.issue.AssignAction; import org.sonar.server.issue.CommentAction; @@ -374,7 +374,8 @@ public class PlatformLevel4 extends PlatformLevel { NewAlerts.class, NewAlerts.newMetadata(), ComponentCleanerService.class, - FavoriteService.class, + + FavoriteModule.class, // views ViewIndexDefinition.class, diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java index 636243d7426..b0f5fc8df2c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java @@ -37,6 +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.i18n.I18nRule; import org.sonar.server.permission.PermissionTemplateService; import org.sonar.server.tester.UserSessionRule; diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/queue/ReportSubmitterTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/queue/ReportSubmitterTest.java index 4ac952e8572..9c8f148c988 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/queue/ReportSubmitterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/queue/ReportSubmitterTest.java @@ -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.component.FavoriteService; +import org.sonar.server.favorite.FavoriteService; import org.sonar.server.component.NewComponent; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.permission.PermissionTemplateService; diff --git a/server/sonar-server/src/test/java/org/sonar/server/favorite/FavoriteModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/favorite/FavoriteModuleTest.java new file mode 100644 index 00000000000..22c4bf1de6c --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/favorite/FavoriteModuleTest.java @@ -0,0 +1,35 @@ +/* + * 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.Test; +import org.sonar.core.platform.ComponentContainer; + +import static org.assertj.core.api.Assertions.assertThat; + +public class FavoriteModuleTest { + @Test + public void verify_count_of_added_components() { + ComponentContainer container = new ComponentContainer(); + new FavoriteModule().configure(container); + assertThat(container.size()).isEqualTo(3 + 2); + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/FavoriteServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/favorite/FavoriteServiceTest.java index 8c5cdafe572..6fce121499a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/FavoriteServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/favorite/FavoriteServiceTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.component; +package org.sonar.server.favorite; import org.junit.Rule; import org.junit.Test; diff --git a/server/sonar-server/src/test/java/org/sonar/server/favorite/ws/AddActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/favorite/ws/AddActionTest.java index 3b951b5bdcd..99d04fa81f0 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/favorite/ws/AddActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/favorite/ws/AddActionTest.java @@ -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.component.FavoriteService; +import org.sonar.server.favorite.FavoriteService; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.exceptions.UnauthorizedException; diff --git a/server/sonar-server/src/test/java/org/sonar/server/favorite/ws/FavoritesWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/favorite/ws/FavoritesWsTest.java index 470c83212dd..52f9e11be24 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/favorite/ws/FavoritesWsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/favorite/ws/FavoritesWsTest.java @@ -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.component.FavoriteService; +import org.sonar.server.favorite.FavoriteService; import org.sonar.server.user.UserSession; import org.sonar.server.ws.WsTester; diff --git a/server/sonar-web/src/main/js/api/favorites.js b/server/sonar-web/src/main/js/api/favorites.js index 2c7149bd3c4..3bb5872aa1e 100644 --- a/server/sonar-web/src/main/js/api/favorites.js +++ b/server/sonar-web/src/main/js/api/favorites.js @@ -25,8 +25,8 @@ export const getFavorites = (): Promise<Object> => ( ); export function addFavorite (componentKey: string) { - const url = '/api/favourites'; - const data = { key: componentKey }; + const url = '/api/favorites'; + const data = { component: componentKey }; return post(url, data); } diff --git a/server/sonar-web/src/main/js/components/source-viewer/header.js b/server/sonar-web/src/main/js/components/source-viewer/header.js index 5e3ed9e866b..d0248f1a02c 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/header.js +++ b/server/sonar-web/src/main/js/components/source-viewer/header.js @@ -25,7 +25,8 @@ import MoreActionsView from './more-actions'; import MeasuresOverlay from './measures-overlay'; import Template from './templates/source-viewer-header.hbs'; -const API_FAVORITE: string = window.baseUrl + '/api/favourites'; +const API_FAVOURITE: string = window.baseUrl + '/api/favourites'; +const API_FAVORITE: string = window.baseUrl + '/api/favorites'; export default Marionette.ItemView.extend({ template: Template, @@ -42,7 +43,7 @@ export default Marionette.ItemView.extend({ const that = this; if (this.model.get('fav')) { $.ajax({ - url: API_FAVORITE + '/' + this.model.get('key'), + url: API_FAVOURITE + '/' + this.model.get('key'), type: 'DELETE' }).done(function () { that.model.set('fav', false); @@ -53,7 +54,7 @@ export default Marionette.ItemView.extend({ url: API_FAVORITE, type: 'POST', data: { - key: this.model.get('key') + component: this.model.get('key') } }).done(function () { that.model.set('fav', true); |