@@ -20,6 +20,7 @@ | |||
package org.sonar.server.authentication.ws; | |||
import com.google.common.io.Resources; | |||
import org.sonar.api.server.ws.RailsHandler; | |||
import org.sonar.api.server.ws.WebService; | |||
@@ -33,7 +34,8 @@ public class AuthenticationWs implements WebService { | |||
controller.createAction("validate") | |||
.setDescription("Check credentials") | |||
.setSince("3.3") | |||
.setHandler(RailsHandler.INSTANCE); | |||
.setHandler(RailsHandler.INSTANCE) | |||
.setResponseExample(Resources.getResource(this.getClass(), "example-validate.json")); | |||
controller.done(); | |||
} |
@@ -42,6 +42,7 @@ import org.sonar.core.issue.db.IssueDto; | |||
import org.sonar.core.persistence.MyBatis; | |||
import org.sonar.core.resource.ResourceDao; | |||
import org.sonar.core.rule.DefaultRuleFinder; | |||
import org.sonar.server.issue.actionplan.ActionPlanService; | |||
import org.sonar.server.user.UserSession; | |||
import javax.annotation.CheckForNull; |
@@ -44,6 +44,7 @@ import org.sonar.core.resource.ResourceDao; | |||
import org.sonar.core.resource.ResourceDto; | |||
import org.sonar.core.resource.ResourceQuery; | |||
import org.sonar.server.exceptions.BadRequestException; | |||
import org.sonar.server.issue.actionplan.ActionPlanService; | |||
import org.sonar.server.issue.filter.IssueFilterParameters; | |||
import org.sonar.server.issue.filter.IssueFilterResult; | |||
import org.sonar.server.issue.filter.IssueFilterService; |
@@ -47,6 +47,7 @@ import org.sonar.core.resource.ResourceDao; | |||
import org.sonar.core.resource.ResourceDto; | |||
import org.sonar.core.resource.ResourceQuery; | |||
import org.sonar.core.user.AuthorizationDao; | |||
import org.sonar.server.issue.actionplan.ActionPlanService; | |||
import org.sonar.server.user.UserSession; | |||
import javax.annotation.Nullable; |
@@ -27,6 +27,7 @@ import org.sonar.api.issue.Issue; | |||
import org.sonar.api.issue.condition.IsUnResolved; | |||
import org.sonar.api.issue.internal.DefaultIssue; | |||
import org.sonar.core.issue.IssueUpdater; | |||
import org.sonar.server.issue.actionplan.ActionPlanService; | |||
import org.sonar.server.user.UserSession; | |||
import java.util.List; |
@@ -18,7 +18,7 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.issue; | |||
package org.sonar.server.issue.actionplan; | |||
import com.google.common.base.Function; | |||
import com.google.common.collect.Iterables; |
@@ -18,8 +18,9 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.issue.ws; | |||
package org.sonar.server.issue.actionplan; | |||
import com.google.common.io.Resources; | |||
import org.sonar.api.server.ws.RailsHandler; | |||
import org.sonar.api.server.ws.WebService; | |||
@@ -33,7 +34,8 @@ public class ActionPlanWs implements WebService { | |||
WebService.NewAction search = controller.createAction("search") | |||
.setDescription("Get a list of action plans. Requires Browse permission on project") | |||
.setSince("3.6") | |||
.setHandler(RailsHandler.INSTANCE); | |||
.setHandler(RailsHandler.INSTANCE) | |||
.setResponseExample(Resources.getResource(this.getClass(), "example-search.json")); | |||
addProjectParam(search); | |||
WebService.NewAction create = controller.createAction("create") |
@@ -0,0 +1,93 @@ | |||
/* | |||
* 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.issue.filter; | |||
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.core.issue.DefaultIssueFilter; | |||
import org.sonar.server.user.UserSession; | |||
import java.util.List; | |||
public class AppAction implements RequestHandler { | |||
private final IssueFilterService service; | |||
private final IssueFilterWriter issueFilterWriter; | |||
public AppAction(IssueFilterService service, IssueFilterWriter issueFilterWriter) { | |||
this.service = service; | |||
this.issueFilterWriter = issueFilterWriter; | |||
} | |||
void define(WebService.NewController controller) { | |||
WebService.NewAction action = controller.createAction("app"); | |||
action | |||
.setDescription("Data required for rendering the page 'Issues'") | |||
.setInternal(true) | |||
.setHandler(this); | |||
action.createParam("id").setDescription("Optionally, the ID of the current filter"); | |||
} | |||
@Override | |||
public void handle(Request request, Response response) throws Exception { | |||
UserSession session = UserSession.get(); | |||
JsonWriter json = response.newJsonWriter(); | |||
json.beginObject(); | |||
// Current filter (optional) | |||
int filterId = request.paramAsInt("id", -1); | |||
DefaultIssueFilter filter = null; | |||
if (filterId >= 0) { | |||
filter = service.find((long) filterId, session); | |||
} | |||
// Permissions | |||
json.prop("canManageFilters", session.isLoggedIn()); | |||
json.prop("canBulkChange", session.isLoggedIn()); | |||
// Selected filter | |||
if (filter != null) { | |||
issueFilterWriter.write(session, filter, json); | |||
} | |||
// Favorite filters, if logged in | |||
if (session.isLoggedIn()) { | |||
List<DefaultIssueFilter> favorites = service.findFavoriteFilters(session); | |||
json.name("favorites").beginArray(); | |||
for (DefaultIssueFilter favorite : favorites) { | |||
json | |||
.beginObject() | |||
.prop("id", favorite.id()) | |||
.prop("name", favorite.name()) | |||
.endObject(); | |||
} | |||
json.endArray(); | |||
} | |||
json.endObject(); | |||
json.close(); | |||
} | |||
} |
@@ -0,0 +1,66 @@ | |||
/* | |||
* 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.issue.filter; | |||
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.core.issue.DefaultIssueFilter; | |||
import org.sonar.server.user.UserSession; | |||
public class FavoritesAction implements RequestHandler { | |||
private final IssueFilterService service; | |||
public FavoritesAction(IssueFilterService service) { | |||
this.service = service; | |||
} | |||
void define(WebService.NewController controller) { | |||
WebService.NewAction action = controller.createAction("favorites"); | |||
action | |||
.setDescription("The issue filters marked as favorite by request user") | |||
.setSince("4.2") | |||
.setHandler(this); | |||
} | |||
@Override | |||
public void handle(Request request, Response response) throws Exception { | |||
UserSession session = UserSession.get(); | |||
JsonWriter json = response.newJsonWriter(); | |||
json.beginObject().name("favoriteFilters").beginArray(); | |||
if (session.isLoggedIn()) { | |||
for (DefaultIssueFilter favorite : service.findFavoriteFilters(session)) { | |||
json.beginObject(); | |||
json.prop("id", favorite.id()); | |||
json.prop("name", favorite.name()); | |||
json.prop("user", favorite.user()); | |||
json.prop("shared", favorite.shared()); | |||
// no need to export description and query fields | |||
json.endObject(); | |||
} | |||
} | |||
json.endArray().endObject().close(); | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
/* | |||
* 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.issue.filter; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.utils.text.JsonWriter; | |||
import org.sonar.core.issue.DefaultIssueFilter; | |||
import org.sonar.core.permission.GlobalPermissions; | |||
import org.sonar.server.user.UserSession; | |||
public class IssueFilterWriter implements ServerComponent { | |||
void write(UserSession session, DefaultIssueFilter filter, JsonWriter json) { | |||
json.name("filter").beginObject() | |||
.prop("id", filter.id()) | |||
.prop("name", filter.name()) | |||
.prop("description", filter.description()) | |||
.prop("user", filter.user()) | |||
.prop("shared", filter.shared()) | |||
.prop("query", filter.data()) | |||
.prop("canModify", canModifyFilter(session, filter)) | |||
.endObject(); | |||
} | |||
private boolean canModifyFilter(UserSession session, DefaultIssueFilter filter) { | |||
return session.isLoggedIn() && | |||
(StringUtils.equals(filter.user(), session.login()) || session.hasGlobalPermission(GlobalPermissions.SYSTEM_ADMIN)); | |||
} | |||
} |
@@ -19,25 +19,18 @@ | |||
*/ | |||
package org.sonar.server.issue.filter; | |||
import org.apache.commons.lang.StringUtils; | |||
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.core.issue.DefaultIssueFilter; | |||
import org.sonar.core.permission.GlobalPermissions; | |||
import org.sonar.server.user.UserSession; | |||
import java.util.List; | |||
public class IssueFilterWs implements WebService { | |||
private static final String PARAM_ID = "id"; | |||
private final IssueFilterService service; | |||
private final AppAction appAction; | |||
private final ShowAction showAction; | |||
private final FavoritesAction favoritesAction; | |||
public IssueFilterWs(IssueFilterService service) { | |||
this.service = service; | |||
public IssueFilterWs(AppAction appAction, ShowAction showAction, FavoritesAction favoritesAction) { | |||
this.appAction = appAction; | |||
this.showAction = showAction; | |||
this.favoritesAction = favoritesAction; | |||
} | |||
@Override | |||
@@ -45,132 +38,10 @@ public class IssueFilterWs implements WebService { | |||
NewController controller = context.createController("api/issue_filters") | |||
.setSince("4.2") | |||
.setDescription("Issue Filters"); | |||
NewAction app = controller.createAction("app"); | |||
app | |||
.setDescription("Data required for rendering the page 'Issues'") | |||
.setInternal(true) | |||
.setHandler(new RequestHandler() { | |||
@Override | |||
public void handle(Request request, Response response) { | |||
app(request, response); | |||
} | |||
}); | |||
app.createParam(PARAM_ID).setDescription("Optionally, the ID of the current filter"); | |||
NewAction show = controller.createAction("show"); | |||
show | |||
.setDescription("Get detail of an issue filter. Requires to be authenticated") | |||
.setSince("4.2") | |||
.setHandler(new RequestHandler() { | |||
@Override | |||
public void handle(Request request, Response response) { | |||
show(request, response); | |||
} | |||
}); | |||
show.createParam(PARAM_ID) | |||
.setDescription("ID of the issue filter") | |||
.setRequired(true); | |||
NewAction fav = controller.createAction("favorites"); | |||
fav | |||
.setDescription("The issue filters marked as favorite by request user") | |||
.setSince("4.2") | |||
.setHandler(new RequestHandler() { | |||
@Override | |||
public void handle(Request request, Response response) { | |||
favorites(request, response); | |||
} | |||
}); | |||
appAction.define(controller); | |||
showAction.define(controller); | |||
favoritesAction.define(controller); | |||
controller.done(); | |||
} | |||
private void app(Request request, Response response) { | |||
UserSession session = UserSession.get(); | |||
JsonWriter json = response.newJsonWriter(); | |||
json.beginObject(); | |||
// Current filter (optional) | |||
int filterId = request.paramAsInt(PARAM_ID, -1); | |||
DefaultIssueFilter filter = null; | |||
if (filterId >= 0) { | |||
filter = service.find((long) filterId, session); | |||
} | |||
// Permissions | |||
json.prop("canManageFilters", session.isLoggedIn()); | |||
json.prop("canBulkChange", session.isLoggedIn()); | |||
// Selected filter | |||
if (filter != null) { | |||
json.name("filter"); | |||
writeFilterJson(session, filter, json); | |||
} | |||
// Favorite filters, if logged in | |||
if (session.isLoggedIn()) { | |||
List<DefaultIssueFilter> favorites = service.findFavoriteFilters(session); | |||
json.name("favorites").beginArray(); | |||
for (DefaultIssueFilter favorite : favorites) { | |||
json | |||
.beginObject() | |||
.prop(PARAM_ID, favorite.id()) | |||
.prop("name", favorite.name()) | |||
.endObject(); | |||
} | |||
json.endArray(); | |||
} | |||
json.endObject(); | |||
json.close(); | |||
} | |||
private void show(Request request, Response response) { | |||
UserSession session = UserSession.get(); | |||
DefaultIssueFilter filter = service.find(Long.parseLong(request.mandatoryParam(PARAM_ID)), session); | |||
JsonWriter json = response.newJsonWriter(); | |||
json.beginObject(); | |||
json.name("filter"); | |||
writeFilterJson(session, filter, json); | |||
json.endObject(); | |||
json.close(); | |||
} | |||
private void favorites(Request request, Response response) { | |||
UserSession session = UserSession.get(); | |||
JsonWriter json = response.newJsonWriter(); | |||
json.beginObject().name("favoriteFilters").beginArray(); | |||
if (session.isLoggedIn()) { | |||
for (DefaultIssueFilter favorite : service.findFavoriteFilters(session)) { | |||
json.beginObject(); | |||
json.prop(PARAM_ID, favorite.id()); | |||
json.prop("name", favorite.name()); | |||
json.prop("user", favorite.user()); | |||
json.prop("shared", favorite.shared()); | |||
// no need to export description and query fields | |||
json.endObject(); | |||
} | |||
} | |||
json.endArray().endObject().close(); | |||
} | |||
private JsonWriter writeFilterJson(UserSession session, DefaultIssueFilter filter, JsonWriter json) { | |||
return json.beginObject() | |||
.prop(PARAM_ID, filter.id()) | |||
.prop("name", filter.name()) | |||
.prop("description", filter.description()) | |||
.prop("user", filter.user()) | |||
.prop("shared", filter.shared()) | |||
.prop("query", filter.data()) | |||
.prop("canModify", canModifyFilter(session, filter)) | |||
.endObject(); | |||
} | |||
private boolean canModifyFilter(UserSession session, DefaultIssueFilter filter) { | |||
return session.isLoggedIn() && | |||
(StringUtils.equals(filter.user(), session.login()) || session.hasGlobalPermission(GlobalPermissions.SYSTEM_ADMIN)); | |||
} | |||
} |
@@ -0,0 +1,65 @@ | |||
/* | |||
* 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.issue.filter; | |||
import com.google.common.io.Resources; | |||
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.core.issue.DefaultIssueFilter; | |||
import org.sonar.server.user.UserSession; | |||
public class ShowAction implements RequestHandler { | |||
private final IssueFilterService service; | |||
private final IssueFilterWriter issueFilterWriter; | |||
public ShowAction(IssueFilterService service, IssueFilterWriter issueFilterWriter) { | |||
this.service = service; | |||
this.issueFilterWriter = issueFilterWriter; | |||
} | |||
void define(WebService.NewController controller) { | |||
WebService.NewAction action = controller.createAction("show"); | |||
action | |||
.setDescription("Get detail of an issue filter. Requires to be authenticated") | |||
.setSince("4.2") | |||
.setHandler(this) | |||
.setResponseExample(Resources.getResource(this.getClass(), "example-show.json")); | |||
action.createParam("id") | |||
.setDescription("ID of the issue filter") | |||
.setRequired(true); | |||
} | |||
@Override | |||
public void handle(Request request, Response response) throws Exception { | |||
UserSession session = UserSession.get(); | |||
DefaultIssueFilter filter = service.find(Long.parseLong(request.mandatoryParam("id")), session); | |||
JsonWriter json = response.newJsonWriter(); | |||
json.beginObject(); | |||
issueFilterWriter.write(session, filter, json); | |||
json.endObject(); | |||
json.close(); | |||
} | |||
} |
@@ -32,6 +32,7 @@ import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic; | |||
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.user.User; | |||
import org.sonar.api.utils.DateUtils; | |||
import org.sonar.api.utils.Duration; | |||
@@ -58,7 +59,7 @@ import java.util.List; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
public class IssueShowWsHandler implements RequestHandler { | |||
public class IssueShowAction implements RequestHandler { | |||
private final IssueFinder issueFinder; | |||
private final IssueService issueService; | |||
@@ -68,8 +69,8 @@ public class IssueShowWsHandler implements RequestHandler { | |||
private final I18n i18n; | |||
private final Durations durations; | |||
public IssueShowWsHandler(IssueFinder issueFinder, IssueService issueService, IssueChangelogService issueChangelogService, ActionService actionService, | |||
DebtModelService debtModel, I18n i18n, Durations durations) { | |||
public IssueShowAction(IssueFinder issueFinder, IssueService issueService, IssueChangelogService issueChangelogService, ActionService actionService, | |||
DebtModelService debtModel, I18n i18n, Durations durations) { | |||
this.issueFinder = issueFinder; | |||
this.issueService = issueService; | |||
this.issueChangelogService = issueChangelogService; | |||
@@ -79,6 +80,16 @@ public class IssueShowWsHandler implements RequestHandler { | |||
this.durations = durations; | |||
} | |||
void define (WebService.NewController controller) { | |||
WebService.NewAction action = controller.createAction("show") | |||
.setDescription("Detail of issue") | |||
.setSince("4.2") | |||
.setInternal(true) | |||
.setHandler(this); | |||
action.createParam("key") | |||
.setDescription("Issue key"); | |||
} | |||
@Override | |||
public void handle(Request request, Response response) { | |||
String issueKey = request.mandatoryParam("key"); |
@@ -19,13 +19,15 @@ | |||
*/ | |||
package org.sonar.server.issue.ws; | |||
import org.sonar.api.rule.Severity; | |||
import org.sonar.api.server.ws.RailsHandler; | |||
import org.sonar.api.server.ws.WebService; | |||
public class IssuesWs implements WebService { | |||
private final IssueShowWsHandler showHandler; | |||
private final IssueShowAction showHandler; | |||
public IssuesWs(IssueShowWsHandler showHandler) { | |||
public IssuesWs(IssueShowAction showHandler) { | |||
this.showHandler = showHandler; | |||
} | |||
@@ -33,13 +35,20 @@ public class IssuesWs implements WebService { | |||
public void define(Context context) { | |||
NewController controller = context.createController("api/issues"); | |||
controller.setDescription("Coding rule issues"); | |||
controller.setSince("3.6"); | |||
showHandler.define(controller); | |||
controller.createAction("show") | |||
.setDescription("Detail of issue") | |||
.setSince("4.2") | |||
.setInternal(true) | |||
.setHandler(showHandler) | |||
.createParam("key", "Issue key"); | |||
WebService.NewAction search = controller.createAction("search") | |||
.setDescription("Get a list of issues. If the number of issues is greater than 10,000, only the first 10,000 ones are returned by the web service. Requires Browse permission on project(s).") | |||
.setSince("3.6") | |||
.setHandler(RailsHandler.INSTANCE); | |||
search.createParam("issues") | |||
.setDescription("Comma-separated list of issue keys.") | |||
.setExampleValue("5bccd6e8-f525-43a2-8d76-fcb13dde79ef"); | |||
search.createParam("severities") | |||
.setDescription("Comma-separated list of severities.") | |||
.setExampleValue("BLOCKER,CRITICAL") | |||
.setPossibleValues(Severity.ALL.toArray(new String[Severity.ALL.size()])); | |||
controller.done(); | |||
} |
@@ -19,10 +19,6 @@ | |||
*/ | |||
package org.sonar.server.platform; | |||
import org.sonar.server.cluster.LocalNonBlockingWorkQueue; | |||
import org.sonar.server.rule2.RuleDao; | |||
import org.sonar.server.rule2.RuleService; | |||
import com.google.common.collect.Lists; | |||
import org.apache.commons.configuration.BaseConfiguration; | |||
import org.sonar.api.config.EmailSettings; | |||
@@ -82,6 +78,7 @@ import org.sonar.jpa.session.DefaultDatabaseConnector; | |||
import org.sonar.jpa.session.ThreadLocalDatabaseSessionFactory; | |||
import org.sonar.server.authentication.ws.AuthenticationWs; | |||
import org.sonar.server.charts.ChartFactory; | |||
import org.sonar.server.cluster.LocalNonBlockingWorkQueue; | |||
import org.sonar.server.component.DefaultComponentFinder; | |||
import org.sonar.server.component.DefaultRubyComponentService; | |||
import org.sonar.server.db.EmbeddedDatabaseFactory; | |||
@@ -91,10 +88,12 @@ import org.sonar.server.debt.*; | |||
import org.sonar.server.es.ESIndex; | |||
import org.sonar.server.es.ESNode; | |||
import org.sonar.server.issue.*; | |||
import org.sonar.server.issue.actionplan.ActionPlanService; | |||
import org.sonar.server.issue.actionplan.ActionPlanWs; | |||
import org.sonar.server.issue.filter.IssueFilterService; | |||
import org.sonar.server.issue.filter.IssueFilterWriter; | |||
import org.sonar.server.issue.filter.IssueFilterWs; | |||
import org.sonar.server.issue.ws.ActionPlanWs; | |||
import org.sonar.server.issue.ws.IssueShowWsHandler; | |||
import org.sonar.server.issue.ws.IssueShowAction; | |||
import org.sonar.server.issue.ws.IssuesWs; | |||
import org.sonar.server.notifications.NotificationCenter; | |||
import org.sonar.server.notifications.NotificationService; | |||
@@ -114,6 +113,7 @@ import org.sonar.server.qualityprofile.ws.QProfileBackupWsHandler; | |||
import org.sonar.server.qualityprofile.ws.QProfilesWs; | |||
import org.sonar.server.rule.*; | |||
import org.sonar.server.rule.ws.*; | |||
import org.sonar.server.rule2.RuleService; | |||
import org.sonar.server.search.IndexUtils; | |||
import org.sonar.server.source.CodeColorizers; | |||
import org.sonar.server.source.DeprecatedSourceDecorator; | |||
@@ -356,19 +356,27 @@ class ServerComponents { | |||
pico.addSingleton(IssueStatsFinder.class); | |||
pico.addSingleton(PublicRubyIssueService.class); | |||
pico.addSingleton(InternalRubyIssueService.class); | |||
pico.addSingleton(ActionPlanService.class); | |||
pico.addSingleton(IssueChangelogService.class); | |||
pico.addSingleton(IssueNotifications.class); | |||
pico.addSingleton(ActionService.class); | |||
pico.addSingleton(Actions.class); | |||
pico.addSingleton(IssueFilterSerializer.class); | |||
pico.addSingleton(IssueFilterService.class); | |||
pico.addSingleton(IssueBulkChangeService.class); | |||
pico.addSingleton(IssueChangelogFormatter.class); | |||
pico.addSingleton(IssueFilterWs.class); | |||
pico.addSingleton(IssueShowWsHandler.class); | |||
pico.addSingleton(IssueShowAction.class); | |||
pico.addSingleton(IssuesWs.class); | |||
// issue filters | |||
pico.addSingleton(IssueFilterService.class); | |||
pico.addSingleton(IssueFilterSerializer.class); | |||
pico.addSingleton(IssueFilterWs.class); | |||
pico.addSingleton(IssueFilterWriter.class); | |||
pico.addSingleton(org.sonar.server.issue.filter.AppAction.class); | |||
pico.addSingleton(org.sonar.server.issue.filter.ShowAction.class); | |||
pico.addSingleton(org.sonar.server.issue.filter.FavoritesAction.class); | |||
// action plan | |||
pico.addSingleton(ActionPlanWs.class); | |||
pico.addSingleton(ActionPlanService.class); | |||
// issues actions | |||
pico.addSingleton(AssignAction.class); |
@@ -0,0 +1 @@ | |||
{"validate": true} |
@@ -0,0 +1,27 @@ | |||
{ | |||
"actionPlans": [ | |||
{ | |||
"key": "3f19de90-1521-4482-a737-a311758ff513", | |||
"name": "Version 3.6", | |||
"status": "OPEN", | |||
"project": "java-sonar-runner-simple", | |||
"userLogin": "admin", | |||
"deadLine": "2013-12-31T00:00:00+0100", | |||
"totalIssues": 1, | |||
"unresolvedIssues": 0, | |||
"createdAt": "2013-05-31T22:40:50+0200", | |||
"updatedAt": "2013-05-31T22:40:50+0200" | |||
}, | |||
{ | |||
"key": "8ab022c0-f0dc-41b7-a762-82502bda749f", | |||
"name": "Version 3.5", | |||
"status": "CLOSED", | |||
"project": "java-sonar-runner-simple4", | |||
"userLogin": "admin", | |||
"totalIssues": 0, | |||
"unresolvedIssues": 0, | |||
"createdAt": "2013-05-31T22:40:30+0200", | |||
"updatedAt": "2013-05-31T22:42:13+0200" | |||
} | |||
] | |||
} |
@@ -0,0 +1,10 @@ | |||
{ | |||
"filter": { | |||
"id": 1, | |||
"name": "My Filter", | |||
"user": "admin", | |||
"shared": true, | |||
"query": "statuses=OPEN,REOPENED|sort=UPDATE_DATE|asc=false", | |||
"canModify": true | |||
} | |||
} |
@@ -219,7 +219,7 @@ class Api::IssuesController < Api::ApiController | |||
require_parameters :issue | |||
plan = nil | |||
plan = params[:plan] if params[:plan] && !params[:plan].blank? | |||
plan = params[:actionplan] if params[:actionplan] && !params[:actionplan].blank? | |||
result = Internal.issues.plan(params[:issue], plan) | |||
render_result_issue(result) | |||
end |
@@ -83,7 +83,7 @@ class IssueController < ApplicationController | |||
elsif action_type=='severity' | |||
issue_result = Internal.issues.setSeverity(issue_key, params[:severity]) | |||
elsif action_type=='plan' | |||
issue_result = Internal.issues.plan(issue_key, params[:plan]) | |||
issue_result = Internal.issues.plan(issue_key, params[:actionplan]) | |||
elsif action_type=='unplan' | |||
issue_result = Internal.issues.plan(issue_key, nil) | |||
else |
@@ -41,9 +41,7 @@ public class AuthenticationWsTest { | |||
WebService.Action validate = controller.action("validate"); | |||
assertThat(validate).isNotNull(); | |||
assertThat(validate.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(validate.since()).isEqualTo("3.3"); | |||
assertThat(validate.isPost()).isFalse(); | |||
assertThat(validate.isInternal()).isFalse(); | |||
assertThat(validate.responseExampleAsString()).isNotEmpty(); | |||
assertThat(validate.params()).isEmpty(); | |||
} | |||
} |
@@ -43,6 +43,7 @@ import org.sonar.core.persistence.MyBatis; | |||
import org.sonar.core.resource.ResourceDao; | |||
import org.sonar.core.rule.DefaultRuleFinder; | |||
import org.sonar.core.user.DefaultUser; | |||
import org.sonar.server.issue.actionplan.ActionPlanService; | |||
import java.util.Collections; | |||
import java.util.List; |
@@ -41,6 +41,7 @@ import org.sonar.core.resource.ResourceDao; | |||
import org.sonar.core.resource.ResourceDto; | |||
import org.sonar.core.resource.ResourceQuery; | |||
import org.sonar.server.exceptions.BadRequestException; | |||
import org.sonar.server.issue.actionplan.ActionPlanService; | |||
import org.sonar.server.issue.filter.IssueFilterService; | |||
import org.sonar.server.user.UserSession; | |||
@@ -50,6 +50,7 @@ import org.sonar.core.resource.ResourceDto; | |||
import org.sonar.core.resource.ResourceQuery; | |||
import org.sonar.core.user.AuthorizationDao; | |||
import org.sonar.core.user.DefaultUser; | |||
import org.sonar.server.issue.actionplan.ActionPlanService; | |||
import org.sonar.server.user.UserSession; | |||
import java.util.Collections; |
@@ -30,6 +30,7 @@ import org.sonar.api.issue.internal.DefaultIssue; | |||
import org.sonar.api.issue.internal.IssueChangeContext; | |||
import org.sonar.core.issue.DefaultActionPlan; | |||
import org.sonar.core.issue.IssueUpdater; | |||
import org.sonar.server.issue.actionplan.ActionPlanService; | |||
import org.sonar.server.user.UserSession; | |||
import java.util.List; |
@@ -18,8 +18,9 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.issue; | |||
package org.sonar.server.issue.actionplan; | |||
import org.fest.assertions.Fail; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
@@ -48,7 +49,6 @@ import java.util.Collection; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.fest.assertions.Fail.fail; | |||
import static org.mockito.Matchers.any; | |||
import static org.mockito.Matchers.eq; | |||
import static org.mockito.Mockito.*; | |||
@@ -103,7 +103,7 @@ public class ActionPlanServiceTest { | |||
try { | |||
actionPlanService.create(actionPlan, unauthorizedUserSession); | |||
fail(); | |||
Fail.fail(); | |||
} catch (Exception e) { | |||
assertThat(e).isInstanceOf(ForbiddenException.class); | |||
} | |||
@@ -195,7 +195,7 @@ public class ActionPlanServiceTest { | |||
try { | |||
actionPlanService.findOpenByProjectKey(projectKey, unauthorizedUserSession); | |||
fail(); | |||
Fail.fail(); | |||
} catch (Exception e) { | |||
assertThat(e).isInstanceOf(ForbiddenException.class); | |||
} |
@@ -0,0 +1,102 @@ | |||
/* | |||
* 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.issue.actionplan; | |||
import org.junit.Test; | |||
import org.sonar.api.server.ws.RailsHandler; | |||
import org.sonar.api.server.ws.WebService; | |||
import org.sonar.server.ws.WsTester; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
public class ActionPlanWsTest { | |||
WsTester tester = new WsTester(new ActionPlanWs()); | |||
@Test | |||
public void define_controller() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
assertThat(controller).isNotNull(); | |||
assertThat(controller.description()).isNotEmpty(); | |||
assertThat(controller.actions()).hasSize(6); | |||
} | |||
@Test | |||
public void define_search_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
WebService.Action action = controller.action("search"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(action.responseExampleAsString()).isNotEmpty(); | |||
assertThat(action.params()).hasSize(1); | |||
} | |||
@Test | |||
public void define_create_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
WebService.Action action = controller.action("create"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(action.params()).hasSize(4); | |||
} | |||
@Test | |||
public void define_delete_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
WebService.Action action = controller.action("delete"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(action.params()).hasSize(1); | |||
} | |||
@Test | |||
public void define_update_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
WebService.Action action = controller.action("update"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(action.params()).hasSize(4); | |||
} | |||
@Test | |||
public void define_open_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
WebService.Action action = controller.action("open"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(action.params()).hasSize(1); | |||
} | |||
@Test | |||
public void define_close_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
WebService.Action action = controller.action("close"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(action.params()).hasSize(1); | |||
} | |||
} |
@@ -0,0 +1,102 @@ | |||
/* | |||
* 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.issue.filter; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.mockito.Mock; | |||
import org.mockito.runners.MockitoJUnitRunner; | |||
import org.sonar.core.issue.DefaultIssueFilter; | |||
import org.sonar.server.user.MockUserSession; | |||
import org.sonar.server.ws.WsTester; | |||
import java.util.Arrays; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
@RunWith(MockitoJUnitRunner.class) | |||
public class AppActionTest { | |||
@Mock | |||
IssueFilterService service; | |||
IssueFilterWriter writer = new IssueFilterWriter(); | |||
AppAction action; | |||
WsTester tester; | |||
@Before | |||
public void setUp() throws Exception { | |||
action = new AppAction(service, writer); | |||
tester = new WsTester(new IssueFilterWs(action, mock(ShowAction.class), mock(FavoritesAction.class))); | |||
} | |||
@Test | |||
public void anonymous_app() throws Exception { | |||
MockUserSession.set().setLogin(null); | |||
tester.newRequest("app").execute().assertJson(getClass(), "anonymous_page.json"); | |||
} | |||
@Test | |||
public void logged_in_app() throws Exception { | |||
MockUserSession.set().setLogin("eric").setUserId(123); | |||
tester.newRequest("app").execute() | |||
.assertJson(getClass(), "logged_in_page.json"); | |||
} | |||
@Test | |||
public void logged_in_app_with_favorites() throws Exception { | |||
MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123); | |||
when(service.findFavoriteFilters(session)).thenReturn(Arrays.asList( | |||
new DefaultIssueFilter().setId(6L).setName("My issues"), | |||
new DefaultIssueFilter().setId(13L).setName("Blocker issues") | |||
)); | |||
tester.newRequest("app").execute() | |||
.assertJson(getClass(), "logged_in_page_with_favorites.json"); | |||
} | |||
@Test | |||
public void logged_in_app_with_selected_filter() throws Exception { | |||
MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123); | |||
when(service.find(13L, session)).thenReturn( | |||
new DefaultIssueFilter().setId(13L).setName("Blocker issues").setData("severity=BLOCKER").setUser("eric") | |||
); | |||
tester.newRequest("app").setParam("id", "13").execute() | |||
.assertJson(getClass(), "logged_in_page_with_selected_filter.json"); | |||
} | |||
@Test | |||
public void app_selected_filter_can_not_be_modified() throws Exception { | |||
// logged-in user is 'eric' but filter is owned by 'simon' | |||
MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123).setGlobalPermissions("none"); | |||
when(service.find(13L, session)).thenReturn( | |||
new DefaultIssueFilter().setId(13L).setName("Blocker issues").setData("severity=BLOCKER").setUser("simon").setShared(true) | |||
); | |||
tester.newRequest("app").setParam("id", "13").execute() | |||
.assertJson(getClass(), "selected_filter_can_not_be_modified.json"); | |||
} | |||
} |
@@ -0,0 +1,75 @@ | |||
/* | |||
* 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.issue.filter; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.mockito.Mock; | |||
import org.mockito.runners.MockitoJUnitRunner; | |||
import org.sonar.core.issue.DefaultIssueFilter; | |||
import org.sonar.server.user.MockUserSession; | |||
import org.sonar.server.ws.WsTester; | |||
import java.util.Arrays; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
@RunWith(MockitoJUnitRunner.class) | |||
public class FavoritesActionTest { | |||
@Mock | |||
IssueFilterService service; | |||
@Mock | |||
IssueFilterWriter writer; | |||
FavoritesAction action; | |||
WsTester tester; | |||
@Before | |||
public void setUp() throws Exception { | |||
action = new FavoritesAction(service); | |||
tester = new WsTester(new IssueFilterWs(mock(AppAction.class), mock(ShowAction.class), action)); | |||
} | |||
@Test | |||
public void favorites_of_anonymous() throws Exception { | |||
MockUserSession.set(); | |||
tester.newRequest("favorites").execute() | |||
.assertJson("{'favoriteFilters': []}"); | |||
} | |||
@Test | |||
public void favorites_of_logged_in_user() throws Exception { | |||
MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123); | |||
when(service.findFavoriteFilters(session)).thenReturn(Arrays.asList( | |||
new DefaultIssueFilter().setId(13L).setName("Blocker issues").setData("severity=BLOCKER").setUser("simon").setShared(true) | |||
)); | |||
tester.newRequest("favorites").execute() | |||
.assertJson("{'favoriteFilters': [{'id': 13, 'name': 'Blocker issues', 'user': 'simon', 'shared': true}]}"); | |||
} | |||
} |
@@ -0,0 +1,115 @@ | |||
/* | |||
* 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.issue.filter; | |||
import org.json.JSONException; | |||
import org.junit.Test; | |||
import org.skyscreamer.jsonassert.JSONAssert; | |||
import org.sonar.api.utils.text.JsonWriter; | |||
import org.sonar.core.issue.DefaultIssueFilter; | |||
import org.sonar.core.permission.GlobalPermissions; | |||
import org.sonar.server.user.MockUserSession; | |||
import org.sonar.server.user.UserSession; | |||
import java.io.StringWriter; | |||
public class IssueFilterWriterTest { | |||
IssueFilterWriter writer = new IssueFilterWriter(); | |||
@Test | |||
public void write_filter() throws Exception { | |||
UserSession userSession = MockUserSession.set(); | |||
test(userSession, | |||
new DefaultIssueFilter() | |||
.setId(13L) | |||
.setName("Blocker issues") | |||
.setDescription("All Blocker Issues") | |||
.setShared(true) | |||
.setUser("simon") | |||
.setData("severity=BLOCKER"), | |||
"{\"filter\":{\n" + | |||
" \"id\":13,\n" + | |||
" \"name\":\"Blocker issues\",\n" + | |||
" \"description\":\"All Blocker Issues\",\n" + | |||
" \"shared\":true,\n" + | |||
" \"query\":\"severity=BLOCKER\",\n" + | |||
" \"user\":\"simon\",\n" + | |||
" \"canModify\":false\n" + | |||
" }}" | |||
); | |||
} | |||
@Test | |||
public void can_modify_if_logged_user_own_filter() throws Exception { | |||
UserSession userSession = MockUserSession.set().setLogin("simon"); | |||
test(userSession, | |||
new DefaultIssueFilter() | |||
.setId(13L) | |||
.setName("Blocker issues") | |||
.setDescription("All Blocker Issues") | |||
.setShared(true) | |||
.setUser("simon") | |||
.setData("severity=BLOCKER"), | |||
"{\"filter\":{\n" + | |||
" \"id\":13,\n" + | |||
" \"name\":\"Blocker issues\",\n" + | |||
" \"description\":\"All Blocker Issues\",\n" + | |||
" \"shared\":true,\n" + | |||
" \"query\":\"severity=BLOCKER\",\n" + | |||
" \"user\":\"simon\",\n" + | |||
" \"canModify\":true\n" + | |||
" }}" | |||
); | |||
} | |||
@Test | |||
public void can_modify_if_logged_user_has_permission() throws Exception { | |||
UserSession userSession = MockUserSession.set().setLogin("simon").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN); | |||
test(userSession, | |||
new DefaultIssueFilter() | |||
.setId(13L) | |||
.setName("Blocker issues") | |||
.setDescription("All Blocker Issues") | |||
.setShared(true) | |||
.setUser("julien") | |||
.setData("severity=BLOCKER"), | |||
"{\"filter\":{\n" + | |||
" \"id\":13,\n" + | |||
" \"name\":\"Blocker issues\",\n" + | |||
" \"description\":\"All Blocker Issues\",\n" + | |||
" \"shared\":true,\n" + | |||
" \"query\":\"severity=BLOCKER\",\n" + | |||
" \"user\":\"julien\",\n" + | |||
" \"canModify\":true\n" + | |||
" }}" | |||
); | |||
} | |||
private void test(UserSession userSession, DefaultIssueFilter filter, String expected) throws JSONException { | |||
StringWriter output = new StringWriter(); | |||
JsonWriter jsonWriter = JsonWriter.of(output); | |||
jsonWriter.beginObject(); | |||
writer.write(userSession, filter, jsonWriter); | |||
jsonWriter.endObject(); | |||
JSONAssert.assertEquals(output.toString(), expected, true); | |||
} | |||
} |
@@ -19,25 +19,34 @@ | |||
*/ | |||
package org.sonar.server.issue.filter; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.mockito.Mock; | |||
import org.mockito.runners.MockitoJUnitRunner; | |||
import org.sonar.api.server.ws.WebService; | |||
import org.sonar.core.issue.DefaultIssueFilter; | |||
import org.sonar.server.exceptions.NotFoundException; | |||
import org.sonar.server.user.MockUserSession; | |||
import org.sonar.server.ws.WsTester; | |||
import java.util.Arrays; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.fest.assertions.Fail.fail; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
@RunWith(MockitoJUnitRunner.class) | |||
public class IssueFilterWsTest { | |||
IssueFilterService service = mock(IssueFilterService.class); | |||
IssueFilterWs ws = new IssueFilterWs(service); | |||
WsTester tester = new WsTester(ws); | |||
@Mock | |||
IssueFilterService service; | |||
@Mock | |||
IssueFilterWriter issueFilterWriter; | |||
IssueFilterWs ws; | |||
WsTester tester; | |||
@Before | |||
public void setUp() throws Exception { | |||
ws = new IssueFilterWs(new AppAction(service, issueFilterWriter), new ShowAction(service, issueFilterWriter), new FavoritesAction(service)); | |||
tester = new WsTester(ws); | |||
} | |||
@Test | |||
public void define_ws() throws Exception { | |||
@@ -48,127 +57,16 @@ public class IssueFilterWsTest { | |||
WebService.Action app = controller.action("app"); | |||
assertThat(app).isNotNull(); | |||
assertThat(app.handler()).isNotNull(); | |||
assertThat(app.isPost()).isFalse(); | |||
assertThat(app.isInternal()).isTrue(); | |||
assertThat(app.since()).isEqualTo("4.2"); | |||
assertThat(app.params()).hasSize(1); | |||
WebService.Param appId = app.param("id"); | |||
assertThat(appId).isNotNull(); | |||
assertThat(appId.description()).isNotNull(); | |||
assertThat(appId.isRequired()).isFalse(); | |||
WebService.Action show = controller.action("show"); | |||
assertThat(show).isNotNull(); | |||
assertThat(show.handler()).isNotNull(); | |||
assertThat(show.isPost()).isFalse(); | |||
assertThat(show.isInternal()).isFalse(); | |||
assertThat(show.since()).isEqualTo("4.2"); | |||
assertThat(show.responseExampleAsString()).isNotEmpty(); | |||
assertThat(show.params()).hasSize(1); | |||
WebService.Param showId = show.param("id"); | |||
assertThat(showId).isNotNull(); | |||
assertThat(showId.description()).isNotNull(); | |||
assertThat(showId.isRequired()).isTrue(); | |||
WebService.Action favorites = controller.action("favorites"); | |||
assertThat(favorites).isNotNull(); | |||
assertThat(favorites.handler()).isNotNull(); | |||
assertThat(favorites.isPost()).isFalse(); | |||
assertThat(favorites.isInternal()).isFalse(); | |||
assertThat(favorites.since()).isEqualTo("4.2"); | |||
assertThat(favorites.params()).isEmpty(); | |||
} | |||
@Test | |||
public void anonymous_app() throws Exception { | |||
MockUserSession.set().setLogin(null); | |||
tester.newRequest("app").execute().assertJson(getClass(), "anonymous_page.json"); | |||
} | |||
@Test | |||
public void logged_in_app() throws Exception { | |||
MockUserSession.set().setLogin("eric").setUserId(123); | |||
tester.newRequest("app").execute() | |||
.assertJson(getClass(), "logged_in_page.json"); | |||
} | |||
@Test | |||
public void logged_in_app_with_favorites() throws Exception { | |||
MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123); | |||
when(service.findFavoriteFilters(session)).thenReturn(Arrays.asList( | |||
new DefaultIssueFilter().setId(6L).setName("My issues"), | |||
new DefaultIssueFilter().setId(13L).setName("Blocker issues") | |||
)); | |||
tester.newRequest("app").execute() | |||
.assertJson(getClass(), "logged_in_page_with_favorites.json"); | |||
} | |||
@Test | |||
public void logged_in_app_with_selected_filter() throws Exception { | |||
MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123); | |||
when(service.find(13L, session)).thenReturn( | |||
new DefaultIssueFilter().setId(13L).setName("Blocker issues").setData("severity=BLOCKER").setUser("eric") | |||
); | |||
tester.newRequest("app").setParam("id", "13").execute() | |||
.assertJson(getClass(), "logged_in_page_with_selected_filter.json"); | |||
} | |||
@Test | |||
public void app_selected_filter_can_not_be_modified() throws Exception { | |||
// logged-in user is 'eric' but filter is owned by 'simon' | |||
MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123).setGlobalPermissions("none"); | |||
when(service.find(13L, session)).thenReturn( | |||
new DefaultIssueFilter().setId(13L).setName("Blocker issues").setData("severity=BLOCKER").setUser("simon").setShared(true) | |||
); | |||
tester.newRequest("app").setParam("id", "13").execute() | |||
.assertJson(getClass(), "selected_filter_can_not_be_modified.json"); | |||
} | |||
@Test | |||
public void show_filter() throws Exception { | |||
// logged-in user is 'eric' but filter is owned by 'simon' | |||
MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123).setGlobalPermissions("none"); | |||
when(service.find(13L, session)).thenReturn( | |||
new DefaultIssueFilter().setId(13L).setName("Blocker issues").setDescription("All Blocker Issues").setData("severity=BLOCKER").setUser("simon").setShared(true) | |||
); | |||
tester.newRequest("show").setParam("id", "13").execute() | |||
.assertJson(getClass(), "show_filter.json"); | |||
} | |||
@Test | |||
public void show_unknown_filter() throws Exception { | |||
MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123).setGlobalPermissions("none"); | |||
when(service.find(42L, session)).thenThrow(new NotFoundException("Filter 42 does not exist")); | |||
try { | |||
tester.newRequest("show").setParam("id", "42").execute(); | |||
fail(); | |||
} catch (NotFoundException e) { | |||
assertThat(e).hasMessage("Filter 42 does not exist"); | |||
} | |||
} | |||
@Test | |||
public void favorites_of_anonymous() throws Exception { | |||
MockUserSession.set(); | |||
tester.newRequest("favorites").execute() | |||
.assertJson("{'favoriteFilters': []}"); | |||
} | |||
@Test | |||
public void favorites_of_logged_in_user() throws Exception { | |||
MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123); | |||
when(service.findFavoriteFilters(session)).thenReturn(Arrays.asList( | |||
new DefaultIssueFilter().setId(13L).setName("Blocker issues").setData("severity=BLOCKER").setUser("simon").setShared(true) | |||
)); | |||
tester.newRequest("favorites").execute() | |||
.assertJson("{'favoriteFilters': [{'id': 13, 'name': 'Blocker issues', 'user': 'simon', 'shared': true}]}"); | |||
} | |||
} |
@@ -0,0 +1,81 @@ | |||
/* | |||
* 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.issue.filter; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.mockito.Mock; | |||
import org.mockito.runners.MockitoJUnitRunner; | |||
import org.sonar.core.issue.DefaultIssueFilter; | |||
import org.sonar.server.exceptions.NotFoundException; | |||
import org.sonar.server.user.MockUserSession; | |||
import org.sonar.server.ws.WsTester; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.fest.assertions.Fail.fail; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
@RunWith(MockitoJUnitRunner.class) | |||
public class ShowActionTest { | |||
@Mock | |||
IssueFilterService service; | |||
IssueFilterWriter writer = new IssueFilterWriter(); | |||
ShowAction action; | |||
WsTester tester; | |||
@Before | |||
public void setUp() throws Exception { | |||
action = new ShowAction(service, writer); | |||
tester = new WsTester(new IssueFilterWs(mock(AppAction.class), action, mock(FavoritesAction.class))); | |||
} | |||
@Test | |||
public void show_filter() throws Exception { | |||
// logged-in user is 'eric' but filter is owned by 'simon' | |||
MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123).setGlobalPermissions("none"); | |||
when(service.find(13L, session)).thenReturn( | |||
new DefaultIssueFilter().setId(13L).setName("Blocker issues").setDescription("All Blocker Issues").setData("severity=BLOCKER").setUser("simon").setShared(true) | |||
); | |||
tester.newRequest("show").setParam("id", "13").execute() | |||
.assertJson(getClass(), "show_filter.json"); | |||
} | |||
@Test | |||
public void show_unknown_filter() throws Exception { | |||
MockUserSession session = MockUserSession.set().setLogin("eric").setUserId(123).setGlobalPermissions("none"); | |||
when(service.find(42L, session)).thenThrow(new NotFoundException("Filter 42 does not exist")); | |||
try { | |||
tester.newRequest("show").setParam("id", "42").execute(); | |||
fail(); | |||
} catch (NotFoundException e) { | |||
assertThat(e).hasMessage("Filter 42 does not exist"); | |||
} | |||
} | |||
} |
@@ -1,189 +0,0 @@ | |||
/* | |||
* 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.issue.ws; | |||
import org.junit.Test; | |||
import org.sonar.api.server.ws.RailsHandler; | |||
import org.sonar.api.server.ws.WebService; | |||
import org.sonar.server.ws.WsTester; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
public class ActionPlanWsTest { | |||
WsTester tester = new WsTester(new ActionPlanWs()); | |||
@Test | |||
public void define_action_plan_controller() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
assertThat(controller).isNotNull(); | |||
assertThat(controller.description()).isNotEmpty(); | |||
assertThat(controller.actions()).hasSize(6); | |||
} | |||
@Test | |||
public void define_search_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
WebService.Action action = controller.action("search"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(action.since()).isEqualTo("3.6"); | |||
assertThat(action.isPost()).isFalse(); | |||
assertThat(action.isInternal()).isFalse(); | |||
assertThat(action.params()).hasSize(1); | |||
WebService.Param project = action.param("project"); | |||
assertThat(project).isNotNull(); | |||
assertThat(project.description()).isNotNull(); | |||
assertThat(project.exampleValue()).isNotNull(); | |||
assertThat(project.isRequired()).isTrue(); | |||
} | |||
@Test | |||
public void define_create_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
WebService.Action action = controller.action("create"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(action.since()).isEqualTo("3.6"); | |||
assertThat(action.isPost()).isTrue(); | |||
assertThat(action.isInternal()).isFalse(); | |||
assertThat(action.params()).hasSize(4); | |||
WebService.Param name = action.param("name"); | |||
assertThat(name).isNotNull(); | |||
assertThat(name.description()).isNotNull(); | |||
assertThat(name.exampleValue()).isNotNull(); | |||
assertThat(name.isRequired()).isTrue(); | |||
WebService.Param description = action.param("description"); | |||
assertThat(description).isNotNull(); | |||
assertThat(description.description()).isNotNull(); | |||
assertThat(description.isRequired()).isFalse(); | |||
WebService.Param project = action.param("project"); | |||
assertThat(project).isNotNull(); | |||
assertThat(project.description()).isNotNull(); | |||
assertThat(project.exampleValue()).isNotNull(); | |||
assertThat(project.isRequired()).isTrue(); | |||
WebService.Param deadLine = action.param("deadLine"); | |||
assertThat(deadLine).isNotNull(); | |||
assertThat(deadLine.description()).isNotNull(); | |||
assertThat(deadLine.exampleValue()).isNotNull(); | |||
assertThat(deadLine.isRequired()).isFalse(); | |||
} | |||
@Test | |||
public void define_delete_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
WebService.Action action = controller.action("delete"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(action.since()).isEqualTo("3.6"); | |||
assertThat(action.isPost()).isTrue(); | |||
assertThat(action.isInternal()).isFalse(); | |||
assertThat(action.params()).hasSize(1); | |||
WebService.Param key = action.param("key"); | |||
assertThat(key).isNotNull(); | |||
assertThat(key.description()).isNotNull(); | |||
assertThat(key.exampleValue()).isNotNull(); | |||
assertThat(key.isRequired()).isTrue(); | |||
} | |||
@Test | |||
public void define_update_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
WebService.Action action = controller.action("update"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(action.since()).isEqualTo("3.6"); | |||
assertThat(action.isPost()).isTrue(); | |||
assertThat(action.isInternal()).isFalse(); | |||
assertThat(action.params()).hasSize(4); | |||
WebService.Param project = action.param("key"); | |||
assertThat(project).isNotNull(); | |||
assertThat(project.description()).isNotNull(); | |||
assertThat(project.exampleValue()).isNotNull(); | |||
assertThat(project.isRequired()).isTrue(); | |||
WebService.Param name = action.param("name"); | |||
assertThat(name).isNotNull(); | |||
assertThat(name.description()).isNotNull(); | |||
assertThat(name.exampleValue()).isNotNull(); | |||
assertThat(name.isRequired()).isTrue(); | |||
WebService.Param description = action.param("description"); | |||
assertThat(description).isNotNull(); | |||
assertThat(description.description()).isNotNull(); | |||
assertThat(description.isRequired()).isFalse(); | |||
WebService.Param deadLine = action.param("deadLine"); | |||
assertThat(deadLine).isNotNull(); | |||
assertThat(deadLine.description()).isNotNull(); | |||
assertThat(deadLine.exampleValue()).isNotNull(); | |||
assertThat(deadLine.isRequired()).isFalse(); | |||
} | |||
@Test | |||
public void define_open_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
WebService.Action action = controller.action("open"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(action.since()).isEqualTo("3.6"); | |||
assertThat(action.isPost()).isTrue(); | |||
assertThat(action.isInternal()).isFalse(); | |||
assertThat(action.params()).hasSize(1); | |||
WebService.Param key = action.param("key"); | |||
assertThat(key).isNotNull(); | |||
assertThat(key.description()).isNotNull(); | |||
assertThat(key.exampleValue()).isNotNull(); | |||
assertThat(key.isRequired()).isTrue(); | |||
} | |||
@Test | |||
public void define_close_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/action_plans"); | |||
WebService.Action action = controller.action("close"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(action.since()).isEqualTo("3.6"); | |||
assertThat(action.isPost()).isTrue(); | |||
assertThat(action.isInternal()).isFalse(); | |||
assertThat(action.params()).hasSize(1); | |||
WebService.Param key = action.param("key"); | |||
assertThat(key).isNotNull(); | |||
assertThat(key.description()).isNotNull(); | |||
assertThat(key.exampleValue()).isNotNull(); | |||
assertThat(key.isRequired()).isTrue(); | |||
} | |||
} |
@@ -38,7 +38,6 @@ import org.sonar.api.issue.internal.FieldDiffs; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.rules.Rule; | |||
import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic; | |||
import org.sonar.server.ws.WsTester; | |||
import org.sonar.api.user.User; | |||
import org.sonar.api.utils.DateUtils; | |||
import org.sonar.api.utils.Duration; | |||
@@ -56,6 +55,7 @@ import org.sonar.server.issue.IssueChangelogService; | |||
import org.sonar.server.issue.IssueService; | |||
import org.sonar.server.user.MockUserSession; | |||
import org.sonar.server.user.UserSession; | |||
import org.sonar.server.ws.WsTester; | |||
import java.util.ArrayList; | |||
import java.util.Date; | |||
@@ -69,7 +69,7 @@ import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
@RunWith(MockitoJUnitRunner.class) | |||
public class IssueShowWsHandlerTest { | |||
public class IssueShowActionTest { | |||
@Mock | |||
IssueFinder issueFinder; | |||
@@ -113,7 +113,7 @@ public class IssueShowWsHandlerTest { | |||
when(i18n.message(any(Locale.class), eq("created"), eq((String) null))).thenReturn("Created"); | |||
tester = new WsTester(new IssuesWs(new IssueShowWsHandler(issueFinder, issueService, issueChangelogService, actionService, debtModel, i18n, durations))); | |||
tester = new WsTester(new IssuesWs(new IssueShowAction(issueFinder, issueService, issueChangelogService, actionService, debtModel, i18n, durations))); | |||
} | |||
@Test |
@@ -20,23 +20,38 @@ | |||
package org.sonar.server.issue.ws; | |||
import org.junit.Test; | |||
import org.sonar.api.i18n.I18n; | |||
import org.sonar.api.issue.IssueFinder; | |||
import org.sonar.api.server.ws.RailsHandler; | |||
import org.sonar.api.server.ws.WebService; | |||
import org.sonar.api.utils.Durations; | |||
import org.sonar.server.debt.DebtModelService; | |||
import org.sonar.server.issue.ActionService; | |||
import org.sonar.server.issue.IssueChangelogService; | |||
import org.sonar.server.issue.IssueService; | |||
import org.sonar.server.ws.WsTester; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
public class IssuesWsTest { | |||
IssueShowWsHandler showHandler = mock(IssueShowWsHandler.class); | |||
WsTester tester = new WsTester(new IssuesWs(showHandler)); | |||
IssueShowAction showAction = new IssueShowAction(mock(IssueFinder.class), mock(IssueService.class), mock(IssueChangelogService.class), mock(ActionService.class), | |||
mock(DebtModelService.class), mock(I18n.class), mock(Durations.class)); | |||
WsTester tester = new WsTester(new IssuesWs(showAction)); | |||
@Test | |||
public void define_ws() throws Exception { | |||
public void define_controller() throws Exception { | |||
WebService.Controller controller = tester.controller("api/issues"); | |||
assertThat(controller).isNotNull(); | |||
assertThat(controller.description()).isNotEmpty(); | |||
assertThat(controller.since()).isEqualTo("3.6"); | |||
assertThat(controller.actions()).hasSize(2); | |||
} | |||
@Test | |||
public void define_show_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/issues"); | |||
WebService.Action show = controller.action("show"); | |||
assertThat(show).isNotNull(); | |||
@@ -44,7 +59,26 @@ public class IssuesWsTest { | |||
assertThat(show.since()).isEqualTo("4.2"); | |||
assertThat(show.isPost()).isFalse(); | |||
assertThat(show.isInternal()).isTrue(); | |||
assertThat(show.handler()).isSameAs(showHandler); | |||
assertThat(show.handler()).isSameAs(showAction); | |||
WebService.Param key = show.param("key"); | |||
assertThat(key).isNotNull(); | |||
assertThat(key.description()).isNotNull(); | |||
assertThat(key.isRequired()).isFalse(); | |||
} | |||
@Test | |||
public void define_search_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/issues"); | |||
WebService.Action show = controller.action("search"); | |||
assertThat(show).isNotNull(); | |||
assertThat(show.handler()).isNotNull(); | |||
assertThat(show.since()).isEqualTo("3.6"); | |||
assertThat(show.isPost()).isFalse(); | |||
assertThat(show.isInternal()).isFalse(); | |||
assertThat(show.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(show.params()).hasSize(2); | |||
} | |||
} |
@@ -42,9 +42,12 @@ public class SourcesWsTest { | |||
WebService.Action show = controller.action("show"); | |||
assertThat(show).isNotNull(); | |||
assertThat(show.handler()).isNotNull(); | |||
assertThat(show.since()).isEqualTo("4.2"); | |||
assertThat(show.isPost()).isFalse(); | |||
assertThat(show.handler()).isSameAs(showAction); | |||
assertThat(show.params()).hasSize(5); | |||
WebService.Action scm = controller.action("scm"); | |||
assertThat(scm).isNotNull(); | |||
assertThat(scm.handler()).isSameAs(scmAction); | |||
assertThat(scm.params()).hasSize(4); | |||
} | |||
} |
@@ -19,6 +19,7 @@ | |||
*/ | |||
package org.sonar.server.ws; | |||
import com.google.common.io.Resources; | |||
import org.junit.Test; | |||
import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.RequestHandler; | |||
@@ -89,7 +90,7 @@ public class ListingWsTest { | |||
.setSince("4.1") | |||
.setPost(true) | |||
.setInternal(true) | |||
.setResponseExample(getClass().getResource("/org/sonar/server/ws/ListingWsTest/metrics_example.json")) | |||
.setResponseExample(Resources.getResource(getClass(), "ListingWsTest/metrics_example.json")) | |||
.setHandler(new RequestHandler() { | |||
@Override | |||
public void handle(Request request, Response response) { |