Search in sources :

Example 46 with WsTester

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)));
}
Also used : DbClient(org.sonar.db.DbClient) WsTester(org.sonar.server.ws.WsTester) UserSession(org.sonar.server.user.UserSession) Before(org.junit.Before)

Example 47 with WsTester

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)));
}
Also used : DbClient(org.sonar.db.DbClient) WsTester(org.sonar.server.ws.WsTester) UserSession(org.sonar.server.user.UserSession) TemplateUsersAction(org.sonar.server.permission.ws.template.TemplateUsersAction) TemplateGroupsAction(org.sonar.server.permission.ws.template.TemplateGroupsAction) Before(org.junit.Before)

Example 48 with WsTester

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();
}
Also used : InOrder(org.mockito.InOrder) WsTester(org.sonar.server.ws.WsTester) Test(org.junit.Test)

Example 49 with WsTester

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();
    }
}
Also used : WsTester(org.sonar.server.ws.WsTester) Test(org.junit.Test)

Example 50 with WsTester

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();
}
Also used : WsTester(org.sonar.server.ws.WsTester) WebService(org.sonar.api.server.ws.WebService) Test(org.junit.Test)

Aggregations

WsTester (org.sonar.server.ws.WsTester)71 Before (org.junit.Before)50 Test (org.junit.Test)21 DbClient (org.sonar.db.DbClient)18 ComponentFinder (org.sonar.server.component.ComponentFinder)15 WebService (org.sonar.api.server.ws.WebService)12 UserSession (org.sonar.server.user.UserSession)5 Languages (org.sonar.api.resources.Languages)4 QProfileFactory (org.sonar.server.qualityprofile.QProfileFactory)4 UserDto (org.sonar.db.user.UserDto)3 DefaultOrganizationProvider (org.sonar.server.organization.DefaultOrganizationProvider)3 UserJsonWriter (org.sonar.server.user.ws.UserJsonWriter)3 I18n (org.sonar.api.i18n.I18n)2 System2 (org.sonar.api.utils.System2)2 OrganizationDao (org.sonar.db.organization.OrganizationDao)2 RuleRepositoryDto (org.sonar.db.rule.RuleRepositoryDto)2 DefaultOrganization (org.sonar.server.organization.DefaultOrganization)2 UserUpdater (org.sonar.server.user.UserUpdater)2 UserIndex (org.sonar.server.user.index.UserIndex)2 Locale (java.util.Locale)1