use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.
the class UpgradesActionTest method action_updates_is_defined.
@Test
public void action_updates_is_defined() {
WsTester wsTester = new WsTester();
WebService.NewController newController = wsTester.context().createController(DUMMY_CONTROLLER_KEY);
underTest.define(newController);
newController.done();
WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY);
assertThat(controller.actions()).extracting("key").containsExactly("upgrades");
WebService.Action action = controller.actions().iterator().next();
assertThat(action.isPost()).isFalse();
assertThat(action.description()).isNotEmpty();
assertThat(action.responseExample()).isNotNull();
assertThat(action.params()).isEmpty();
}
use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.
the class PluginsWsMediumTest method test_update_existing_and_install_new_scenario.
@Test
public void test_update_existing_and_install_new_scenario() throws Exception {
WsTester wsTester = new WsTester(serverTester.get(PluginsWs.class));
// 1 - check what's installed, available and pending
userSessionRule.logIn().setSystemAdministrator();
wsTester.newGetRequest("api/plugins", "installed").execute().assertJson("{" + " \"plugins\": [" + " {" + " \"key\": \"decoy\"," + " \"version\": \"1.0\"" + " }" + " ]" + "}");
wsTester.newGetRequest("api/plugins", "available").execute().assertJson("{" + " \"plugins\": [" + " {" + " \"key\": \"foo\"," + " \"release\": {" + " \"version\": \"1.0\"" + " }," + " \"update\": {" + " \"status\": \"COMPATIBLE\"," + " \"requires\": []" + " }" + " }" + " ]" + "}");
wsTester.newGetRequest("api/plugins", "pending").execute().assertJson("{\"installing\":[],\"removing\":[],\"updating\":[]}");
// 2 - install one plugin, update another, verify pending status in the process
wsTester.newPostRequest("api/plugins", "update").setParam("key", "decoy").execute().assertNoContent();
wsTester.newGetRequest("api/plugins", "pending").execute().assertJson("{" + " \"updating\": [" + " {" + " \"key\": \"decoy\"," + " \"version\": \"1.1\"" + " }" + " ]," + " \"installing\": []," + " \"removing\": []" + "}");
wsTester.newPostRequest("api/plugins", "install").setParam("key", "foo").execute().assertNoContent();
wsTester.newGetRequest("api/plugins", "pending").execute().assertJson("{" + " \"installing\": [" + " {" + " \"key\": \"foo\"," + " \"version\": \"1.0\"" + " }" + " ]," + " \"updating\": [" + " {" + " \"key\": \"decoy\"," + " \"version\": \"1.1\"" + " }" + " ]," + " \"removing\": []" + "}");
// 3 - simulate SQ restart
wsTester = restartServerTester();
// 4 - make sure plugin is installed
userSessionRule.logIn().setSystemAdministrator();
wsTester.newGetRequest("api/plugins", "installed").execute().assertJson("{" + " \"plugins\": [" + " {" + " \"key\": \"decoy\"," + " \"version\": \"1.1\"" + " }," + " {" + " \"key\": \"foo\"," + " \"version\": \"1.0\"" + " }" + " ]" + "}");
// 5 - uninstall a plugin, verify pending status in the process
wsTester.newPostRequest("api/plugins", "uninstall").setParam("key", "foo").execute().assertNoContent();
wsTester.newGetRequest("api/plugins", "pending").execute().assertJson("{" + " \"installing\": []," + " \"updating\": []," + " \"removing\": [" + " {" + " \"key\": \"foo\"," + " \"version\": \"1.0\"" + " }" + " ]," + "}");
// 6 - simulate SQ restart again
wsTester = restartServerTester();
// 7 - make sure plugin has been uninstalled
userSessionRule.logIn().setSystemAdministrator();
wsTester.newGetRequest("api/plugins", "installed").execute().assertJson("{" + " \"plugins\": [" + " {" + " \"key\": \"decoy\"," + " \"version\": \"1.1\"" + " }" + " ]" + "}");
}
use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.
the class BulkDeleteActionTest method setUp.
@Before
public void setUp() {
ws = new WsTester(new ProjectsWs(underTest));
org1 = db.organizations().insert();
org2 = db.organizations().insert();
}
use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.
the class CancelAllActionTest method action_cancel_all_is_defined.
@Test
public void action_cancel_all_is_defined() {
WsTester wsTester = new WsTester();
WebService.NewController newController = wsTester.context().createController(DUMMY_CONTROLLER_KEY);
underTest.define(newController);
newController.done();
WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY);
assertThat(controller.actions()).extracting("key").containsExactly("cancel_all");
WebService.Action action = controller.actions().iterator().next();
assertThat(action.isPost()).isTrue();
assertThat(action.description()).isNotEmpty();
assertThat(action.responseExample()).isNull();
assertThat(action.params()).isEmpty();
}
use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.
the class InstalledActionTest method action_installed_is_defined.
@Test
public void action_installed_is_defined() {
logInAsSystemAdministrator();
WsTester wsTester = new WsTester();
WebService.NewController newController = wsTester.context().createController(DUMMY_CONTROLLER_KEY);
underTest.define(newController);
newController.done();
WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY);
assertThat(controller.actions()).extracting("key").containsExactly("installed");
WebService.Action action = controller.actions().iterator().next();
assertThat(action.isPost()).isFalse();
assertThat(action.description()).isNotEmpty();
assertThat(action.responseExample()).isNotNull();
}
Aggregations