use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.
the class MetricsWsTest method setUp.
@Before
public void setUp() {
DbClient dbClient = mock(DbClient.class);
UserSession userSession = mock(UserSession.class);
ws = new WsTester(new MetricsWs(new SearchAction(dbClient), new CreateAction(dbClient, userSession), new UpdateAction(dbClient, userSession), new DeleteAction(dbClient, userSession), new TypesAction(), new DomainsAction(dbClient)));
}
use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.
the class PermissionsWsTest method setUp.
@Before
public void setUp() {
DbClient dbClient = mock(DbClient.class);
UserSession userSession = mock(UserSession.class);
PermissionWsSupport permissionWsSupport = mock(PermissionWsSupport.class);
ws = new WsTester(new PermissionsWs(new TemplateUsersAction(dbClient, userSession, permissionWsSupport), new TemplateGroupsAction(dbClient, userSession, permissionWsSupport)));
}
use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.
the class RestartActionTest method restart_if_dev_mode.
@Test
public void restart_if_dev_mode() throws Exception {
settings.setProperty("sonar.web.dev", true);
SystemWs ws = new SystemWs(sut);
WsTester tester = new WsTester(ws);
tester.newPostRequest("api/system", "restart").execute();
InOrder inOrder = Mockito.inOrder(platform, restartFlagHolder);
inOrder.verify(restartFlagHolder).set();
inOrder.verify(platform).restart();
inOrder.verify(restartFlagHolder).unset();
}
use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.
the class RestartActionTest method restart_flag_is_unset_in_dev_mode_even_if_restart_fails.
@Test
public void restart_flag_is_unset_in_dev_mode_even_if_restart_fails() throws Exception {
settings.setProperty("sonar.web.dev", true);
RuntimeException toBeThrown = new RuntimeException("simulating platform.restart() failed");
doThrow(toBeThrown).when(platform).restart();
SystemWs ws = new SystemWs(sut);
WsTester tester = new WsTester(ws);
try {
tester.newPostRequest("api/system", "restart").execute();
} catch (RuntimeException e) {
assertThat(e).isSameAs(toBeThrown);
} finally {
inOrder.verify(restartFlagHolder).set();
inOrder.verify(platform).restart();
inOrder.verify(restartFlagHolder).unset();
}
}
use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.
the class StatusActionTest method action_status_is_defined.
@Test
public void action_status_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("status");
WebService.Action action = controller.actions().iterator().next();
assertThat(action.isPost()).isFalse();
assertThat(action.description()).isNotEmpty();
assertThat(action.responseExample()).isNotNull();
assertThat(action.params()).isEmpty();
}
Aggregations