Search in sources :

Example 16 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 17 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)

Example 18 with WsTester

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

the class DeleteActionTest method setUp.

@Before
public void setUp() {
    xoo1 = LanguageTesting.newLanguage("xoo1");
    xoo2 = LanguageTesting.newLanguage("xoo2");
    tester = new WsTester(new QProfilesWs(mock(RuleActivationActions.class), mock(BulkRuleActivationActions.class), new DeleteAction(new Languages(xoo1, xoo2), new QProfileFactory(dbClient, defaultOrganizationProvider), dbClient, new QProfileWsSupport(userSessionRule, defaultOrganizationProvider))));
}
Also used : QProfileFactory(org.sonar.server.qualityprofile.QProfileFactory) WsTester(org.sonar.server.ws.WsTester) Languages(org.sonar.api.resources.Languages) Before(org.junit.Before)

Example 19 with WsTester

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

the class ExportersActionTest method importers_nominal.

@Test
public void importers_nominal() throws Exception {
    WsTester wsTester = new WsTester(new QProfilesWs(mock(RuleActivationActions.class), mock(BulkRuleActivationActions.class), new ExportersAction(createExporters())));
    wsTester.newGetRequest("api/qualityprofiles", "exporters").execute().assertJson(getClass(), "exporters.json");
}
Also used : WsTester(org.sonar.server.ws.WsTester) Test(org.junit.Test)

Example 20 with WsTester

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

the class QProfileRefTest method define_ws_parameters.

@Test
public void define_ws_parameters() {
    WsTester wsTester = new WsTester();
    WebService.NewController controller = wsTester.context().createController("api/qualityprofiles");
    WebService.NewAction newAction = controller.createAction("do").setHandler((request, response) -> {
    });
    Languages languages = new Languages(new FakeLanguage("java"), new FakeLanguage("js"));
    QProfileRef.defineParams(newAction, languages);
    controller.done();
    WebService.Action action = wsTester.controller("api/qualityprofiles").action("do");
    assertThat(action.param("language")).isNotNull();
    assertThat(action.param("language").possibleValues()).containsOnly("java", "js");
    assertThat(action.param("profileKey")).isNotNull();
    assertThat(action.param("profileName")).isNotNull();
}
Also used : WsTester(org.sonar.server.ws.WsTester) WebService(org.sonar.api.server.ws.WebService) Languages(org.sonar.api.resources.Languages) 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