Search in sources :

Example 11 with NewController

use of org.sonar.api.server.ws.WebService.NewController in project sonarqube by SonarSource.

the class WebServiceTest method fail_if_get_and_no_response_example.

@Test
public void fail_if_get_and_no_response_example() {
    ((WebService) context -> {
        NewController newController = context.createController("api/rule");
        newDefaultAction(newController, "list").setResponseExample(null);
        newController.done();
    }).define(context);
    assertThat(logTester.logs(LoggerLevel.WARN)).contains("The response example is not set on action api/rule/list");
}
Also used : NewController(org.sonar.api.server.ws.WebService.NewController) Test(org.junit.Test)

Example 12 with NewController

use of org.sonar.api.server.ws.WebService.NewController in project sonarqube by SonarSource.

the class WebServiceTest method fail_if_duplicated_action_parameters.

@Test
public void fail_if_duplicated_action_parameters() {
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage("The parameter 'key' is defined multiple times in the action 'create'");
    ((WebService) context -> {
        NewController controller = context.createController("api/rule");
        NewAction action = newDefaultAction(controller, "create");
        action.createParam("key");
        action.createParam("key");
        controller.done();
    }).define(context);
}
Also used : NewAction(org.sonar.api.server.ws.WebService.NewAction) NewController(org.sonar.api.server.ws.WebService.NewController) Test(org.junit.Test)

Example 13 with NewController

use of org.sonar.api.server.ws.WebService.NewController in project sonarqube by SonarSource.

the class WebServiceTest method log_if_action_description_is_empty.

@Test
public void log_if_action_description_is_empty() {
    ((WebService) context -> {
        NewController newController = context.createController("api/rule");
        newDefaultAction(newController, "list").setDescription("");
        newController.done();
    }).define(context);
    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Description is not set on action api/rule/list");
}
Also used : NewController(org.sonar.api.server.ws.WebService.NewController) Test(org.junit.Test)

Example 14 with NewController

use of org.sonar.api.server.ws.WebService.NewController in project sonarqube by SonarSource.

the class WebServiceTest method log_if_action_description_is_null.

@Test
public void log_if_action_description_is_null() {
    ((WebService) context -> {
        NewController newController = context.createController("api/rule");
        newDefaultAction(newController, "list").setDescription(null);
        newController.done();
    }).define(context);
    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Description is not set on action api/rule/list");
}
Also used : NewController(org.sonar.api.server.ws.WebService.NewController) Test(org.junit.Test)

Example 15 with NewController

use of org.sonar.api.server.ws.WebService.NewController in project sonarqube by SonarSource.

the class WebServiceTest method fail_if_duplicated_action_keys.

@Test
public void fail_if_duplicated_action_keys() {
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage("The action 'delete' is defined multiple times in the web service 'rule'");
    ((WebService) context -> {
        NewController newController = context.createController("rule");
        newDefaultAction(newController, "create");
        newDefaultAction(newController, "delete");
        newDefaultAction(newController, "delete");
        newController.done();
    }).define(context);
}
Also used : NewController(org.sonar.api.server.ws.WebService.NewController) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)15 NewController (org.sonar.api.server.ws.WebService.NewController)15 NewAction (org.sonar.api.server.ws.WebService.NewAction)6