Search in sources :

Example 21 with WsTester

use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.

the class UninstallActionTest method action_uninstall_is_defined.

@Test
public void action_uninstall_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(ACTION_KEY);
    WebService.Action action = controller.actions().iterator().next();
    assertThat(action.isPost()).isTrue();
    assertThat(action.description()).isNotEmpty();
    assertThat(action.responseExample()).isNull();
    assertThat(action.params()).hasSize(1);
    WebService.Param keyParam = action.param(KEY_PARAM);
    assertThat(keyParam).isNotNull();
    assertThat(keyParam.isRequired()).isTrue();
    assertThat(keyParam.description()).isNotNull();
}
Also used : WsTester(org.sonar.server.ws.WsTester) WebService(org.sonar.api.server.ws.WebService) Test(org.junit.Test)

Example 22 with WsTester

use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.

the class UpdateActionTest method action_update_is_defined.

@Test
public void action_update_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(ACTION_KEY);
    WebService.Action action = controller.actions().iterator().next();
    assertThat(action.isPost()).isTrue();
    assertThat(action.description()).isNotEmpty();
    assertThat(action.responseExample()).isNull();
    assertThat(action.params()).hasSize(1);
    WebService.Param key = action.param(KEY_PARAM);
    assertThat(key).isNotNull();
    assertThat(key.isRequired()).isTrue();
    assertThat(key.description()).isNotNull();
}
Also used : WsTester(org.sonar.server.ws.WsTester) WebService(org.sonar.api.server.ws.WebService) Test(org.junit.Test)

Example 23 with WsTester

use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.

the class UpdatesActionTest method action_updatable_is_defined.

@Test
public void action_updatable_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("updates");
    WebService.Action action = controller.actions().iterator().next();
    assertThat(action.isPost()).isFalse();
    assertThat(action.description()).isNotEmpty();
    assertThat(action.responseExample()).isNotNull();
}
Also used : WsTester(org.sonar.server.ws.WsTester) WebService(org.sonar.api.server.ws.WebService) Test(org.junit.Test)

Example 24 with WsTester

use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.

the class QualityGatesWsTest method setUp.

@Before
public void setUp() {
    SelectAction selectAction = new SelectAction(mock(DbClient.class), mock(UserSessionRule.class), mock(ComponentFinder.class));
    tester = new WsTester(new QualityGatesWs(new ListAction(qGates), new ShowAction(qGates), new SearchAction(projectFinder), new CreateAction(null, null, null, null), new CopyAction(qGates), new DestroyAction(qGates), new RenameAction(qGates), new SetAsDefaultAction(qGates), new UnsetDefaultAction(qGates), new CreateConditionAction(null, null, null, null), new UpdateConditionAction(null, null, null, null), new DeleteConditionAction(qGates), selectAction, new DeselectAction(qGates, mock(DbClient.class), mock(ComponentFinder.class)), new AppAction(null, null, null)));
}
Also used : DbClient(org.sonar.db.DbClient) ComponentFinder(org.sonar.server.component.ComponentFinder) WsTester(org.sonar.server.ws.WsTester) UserSessionRule(org.sonar.server.tester.UserSessionRule) Before(org.junit.Before)

Example 25 with WsTester

use of org.sonar.server.ws.WsTester in project sonarqube by SonarSource.

the class CompareActionMediumTest method setUp.

@Before
public void setUp() {
    tester.clearDbAndIndexes();
    db = tester.get(DbClient.class);
    session = db.openSession(false);
    wsTester = new WsTester(tester.get(QProfilesWs.class));
}
Also used : DbClient(org.sonar.db.DbClient) WsTester(org.sonar.server.ws.WsTester) Before(org.junit.Before)

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