Skip to content

Commit

Permalink
Remove unused "statuses" field in response of api/rules/app
Browse files Browse the repository at this point in the history
This field is not used by web app
  • Loading branch information
Simon Brandhof authored and sns-seb committed Mar 23, 2017
1 parent bd45c38 commit df6b7d4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
*/
package org.sonar.server.rule.ws;

import java.util.Locale;
import org.sonar.api.i18n.I18n;
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
Expand All @@ -41,14 +38,12 @@ public class AppAction implements RulesWsAction {

private final Languages languages;
private final DbClient dbClient;
private final I18n i18n;
private final UserSession userSession;
private final RuleWsSupport wsSupport;

public AppAction(Languages languages, DbClient dbClient, I18n i18n, UserSession userSession, RuleWsSupport wsSupport) {
public AppAction(Languages languages, DbClient dbClient, UserSession userSession, RuleWsSupport wsSupport) {
this.languages = languages;
this.dbClient = dbClient;
this.i18n = i18n;
this.userSession = userSession;
this.wsSupport = wsSupport;
}
Expand Down Expand Up @@ -81,7 +76,6 @@ public void handle(Request request, Response response) throws Exception {
addProfiles(dbSession, organization, json);
addLanguages(json);
addRuleRepositories(json, dbSession);
addStatuses(json);
json.endObject().close();
}
}
Expand Down Expand Up @@ -130,14 +124,4 @@ private void addRuleRepositories(JsonWriter json, DbSession dbSession) {
.endObject());
json.endArray();
}

private void addStatuses(JsonWriter json) {
json.name("statuses").beginObject();
for (RuleStatus status : RuleStatus.values()) {
if (status != RuleStatus.REMOVED) {
json.prop(status.toString(), i18n.message(Locale.getDefault(), "rules.status." + status.toString().toLowerCase(Locale.ENGLISH), status.toString()));
}
}
json.endObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
*/
package org.sonar.server.rule.ws;

import java.util.Locale;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.i18n.I18n;
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
import org.sonar.api.server.ws.WebService;
Expand All @@ -43,10 +41,6 @@

import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.sonar.test.JsonAssert.assertJson;

public class AppActionTest {
Expand All @@ -63,9 +57,8 @@ public class AppActionTest {

private Languages languages = new Languages(LANG1, LANG2);
private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
private I18n i18n = mock(I18n.class);
private RuleWsSupport wsSupport = new RuleWsSupport(db.getDbClient(), userSession, defaultOrganizationProvider);
private AppAction underTest = new AppAction(languages, db.getDbClient(), i18n, userSession, wsSupport);
private AppAction underTest = new AppAction(languages, db.getDbClient(), userSession, wsSupport);
private WsActionTester tester = new WsActionTester(underTest);

@Test
Expand Down Expand Up @@ -221,8 +214,6 @@ private void insertRules() {
RuleRepositoryDto repo2 = new RuleRepositoryDto("squid", "ws", "SonarQube");
db.getDbClient().ruleRepositoryDao().insert(db.getSession(), asList(repo1, repo2));
db.getSession().commit();
when(i18n.message(isA(Locale.class), anyString(), anyString())).thenAnswer(
invocation -> invocation.getArguments()[1]);
}

private void insertQualityProfiles(OrganizationDto organization) {
Expand Down

0 comments on commit df6b7d4

Please sign in to comment.