import org.sonar.server.rule2.persistence.RuleDao;
import org.sonar.server.rule2.ws.RulesWebService;
import org.sonar.server.rule2.ws.SearchAction;
+import org.sonar.server.rule2.ws.SetNoteAction;
import org.sonar.server.rule2.ws.SetTagsAction;
import org.sonar.server.rule2.ws.TagsAction;
import org.sonar.server.source.CodeColorizers;
pico.addSingleton(org.sonar.server.rule2.ws.ShowAction.class);
pico.addSingleton(TagsAction.class);
pico.addSingleton(SetTagsAction.class);
+ pico.addSingleton(SetNoteAction.class);
pico.addSingleton(org.sonar.server.rule2.ws.AppAction.class);
// measure
private final ShowAction show;
private final TagsAction tags;
private final SetTagsAction setTags;
+ private final SetNoteAction setNote;
private final AppAction app;
- public RulesWebService(SearchAction search, ShowAction show, TagsAction tags, SetTagsAction setTags, AppAction app) {
+ public RulesWebService(SearchAction search, ShowAction show, TagsAction tags,
+ SetTagsAction setTags, SetNoteAction setNote, AppAction app) {
this.search = search;
this.show = show;
this.tags = tags;
this.setTags = setTags;
+ this.setNote = setNote;
this.app = app;
}
show.define(controller);
tags.define(controller);
setTags.define(controller);
+ setNote.define(controller);
app.define(controller);
controller.done();
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.rule2.ws;
+
+import org.sonar.api.rule.RuleKey;
+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.server.rule2.RuleService;
+
+public class SetNoteAction implements RequestHandler {
+
+ private final RuleService service;
+
+ public SetNoteAction(RuleService service) {
+ this.service = service;
+ }
+
+ void define(WebService.NewController controller) {
+ WebService.NewAction setTags = controller
+ .createAction("set_note")
+ .setDescription("Extend the description of a coding rule")
+ .setSince("4.4")
+ .setPost(true)
+ .setHandler(this);
+ setTags
+ .createParam("key")
+ .setRequired(true)
+ .setDescription("Rule key")
+ .setExampleValue("javascript:EmptyBlock");
+ setTags
+ .createParam("text")
+ .setDescription("Markdown text. Set to blank to remove the note.")
+ .setRequired(true)
+ .setExampleValue("java8,security");
+ }
+
+ @Override
+ public void handle(Request request, Response response) {
+ RuleKey key = RuleKey.parse(request.mandatoryParam("key"));
+ service.setNote(key, request.mandatoryParam("text"));
+ }
+}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.qualityprofile;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonar.server.tester.ServerTester;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class ActiveRuleServiceMediumTest {
+
+ @ClassRule
+ public static ServerTester tester = new ServerTester();
+
+ @Test
+ public void activate() throws Exception {
+
+
+ }
+}
}
@Test
- public void update_rules_on_changes() {
+ public void update_and_remove_rules_on_changes() {
execute(new FakeRepositoryV1());
assertThat(dbClient.ruleDao().findAll(dbSession)).hasSize(2);
assertThat(param.getDescription()).isEqualTo("parameter one v2");
assertThat(param.getDefaultValue()).isEqualTo("default1 v2");
- // rule2 has been removed
+ // rule2 has been removed -> status set to REMOVED but db row is not deleted
RuleDto rule2 = dbClient.ruleDao().getByKey(RuleKey.of("fake", "rule2"), dbSession);
assertThat(rule2.getStatus()).isEqualTo(RuleStatus.REMOVED.toString());
assertThat(rule2.getUpdatedAt()).isEqualTo(DATE2);
@Test
public void should_generate_app_init_info() throws Exception {
+ AppAction app = new AppAction(languages, ruleRepositories, i18n, debtModel, qProfiles);
WsTester tester = new WsTester(new RulesWebService(
mock(SearchAction.class), mock(ShowAction.class), mock(TagsAction.class), mock(SetTagsAction.class),
- new AppAction(languages, ruleRepositories, i18n, debtModel, qProfiles)));
-
+ mock(SetNoteAction.class), app));
QProfile profile1 = new QProfile().setName("Profile One").setLanguage("bf");
QProfile profile2 = new QProfile().setName("Profile Two").setLanguage("bf").setParent("Profile One");
WebService.Controller controller = context.controller("api/rules2");
assertThat(controller).isNotNull();
- assertThat(controller.actions()).hasSize(5);
+ assertThat(controller.actions()).hasSize(6);
assertThat(controller.action("search")).isNotNull();
assertThat(controller.action("show")).isNotNull();
assertThat(controller.action("tags")).isNotNull();
assertThat(controller.action("set_tags")).isNotNull();
+ assertThat(controller.action("set_note")).isNotNull();
assertThat(controller.action("app")).isNotNull();
}