Search in sources :

Example 76 with TestRequest

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

the class SendActionTest method executeRequest.

private void executeRequest(@Nullable String to, @Nullable String subject, @Nullable String message) {
    TestRequest request = ws.newRequest();
    if (to != null) {
        request.setParam("to", to);
    }
    if (subject != null) {
        request.setParam("subject", subject);
    }
    if (message != null) {
        request.setParam("message", message);
    }
    request.execute();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Example 77 with TestRequest

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

the class AddActionTest method call.

private TestResponse call(@Nullable String componentKey) {
    TestRequest request = ws.newRequest();
    ofNullable(componentKey).ifPresent(c -> request.setParam(PARAM_COMPONENT, c));
    return request.execute();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Example 78 with TestRequest

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

the class SearchActionTest method call.

private SearchResponse call(@Nullable Integer page, @Nullable Integer pageSize) {
    TestRequest request = ws.newRequest().setMethod(POST.name());
    ofNullable(page).ifPresent(p -> request.setParam(Param.PAGE, p.toString()));
    ofNullable(pageSize).ifPresent(ps -> request.setParam(Param.PAGE_SIZE, ps.toString()));
    return request.executeProtobuf(SearchResponse.class);
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Example 79 with TestRequest

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

the class RemoveActionTest method call.

private TestResponse call(@Nullable String componentKey) {
    TestRequest request = ws.newRequest();
    ofNullable(componentKey).ifPresent(c -> request.setParam(PARAM_COMPONENT, c));
    return request.execute();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Example 80 with TestRequest

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

the class AddCommentActionTest method fails_with_NotFoundException_if_issue_is_not_a_hotspot.

@Test
@UseDataProvider("ruleTypesByHotspot")
public void fails_with_NotFoundException_if_issue_is_not_a_hotspot(RuleType ruleType) {
    ComponentDto project = dbTester.components().insertPublicProject();
    ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
    RuleDefinitionDto rule = dbTester.rules().insert(t -> t.setType(ruleType));
    IssueDto notAHotspot = dbTester.issues().insertIssue(rule, project, file, i -> i.setType(ruleType));
    userSessionRule.logIn();
    TestRequest request = newRequest(notAHotspot, randomAlphabetic(12));
    assertThatThrownBy(request::execute).isInstanceOf(NotFoundException.class).hasMessage("Hotspot '%s' does not exist", notAHotspot.getKey());
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) RuleDefinitionDto(org.sonar.db.rule.RuleDefinitionDto) IssueDto(org.sonar.db.issue.IssueDto) NotFoundException(org.sonar.server.exceptions.NotFoundException) TestRequest(org.sonar.server.ws.TestRequest) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

TestRequest (org.sonar.server.ws.TestRequest)375 Test (org.junit.Test)309 UserDto (org.sonar.db.user.UserDto)82 ComponentDto (org.sonar.db.component.ComponentDto)61 NotFoundException (org.sonar.server.exceptions.NotFoundException)59 ForbiddenException (org.sonar.server.exceptions.ForbiddenException)41 AlmSettingDto (org.sonar.db.alm.setting.AlmSettingDto)29 IssueDto (org.sonar.db.issue.IssueDto)21 RuleDefinitionDto (org.sonar.db.rule.RuleDefinitionDto)21 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)20 QProfileDto (org.sonar.db.qualityprofile.QProfileDto)15 IOException (java.io.IOException)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11 BadRequestException (org.sonar.server.exceptions.BadRequestException)11 ProjectDto (org.sonar.db.project.ProjectDto)10 QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)9 TestResponse (org.sonar.server.ws.TestResponse)9 WsActionTester (org.sonar.server.ws.WsActionTester)9 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)8 Mockito.mock (org.mockito.Mockito.mock)8