Search in sources :

Example 61 with TestResponse

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

the class ListActionTest method return_rules_in_protobuf.

@Test
public void return_rules_in_protobuf() throws Exception {
    dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), RuleTesting.newDto(RuleKey.of("java", "S001")).setConfigKey(null).setName(null));
    dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), RuleTesting.newDto(RuleKey.of("java", "S002")).setConfigKey("I002").setName("Rule Two"));
    dbTester.getSession().commit();
    TestResponse response = tester.newRequest().setMediaType(MediaTypes.PROTOBUF).execute();
    assertThat(response.getMediaType()).isEqualTo(MediaTypes.PROTOBUF);
    Rules.ListResponse listResponse = Rules.ListResponse.parseFrom(response.getInputStream());
    assertThat(listResponse.getRulesCount()).isEqualTo(2);
    assertThat(listResponse.getRules(0).getKey()).isEqualTo("S001");
    assertThat(listResponse.getRules(0).getInternalKey()).isEqualTo("");
    assertThat(listResponse.getRules(0).getName()).isEqualTo("");
    assertThat(listResponse.getRules(1).getKey()).isEqualTo("S002");
    assertThat(listResponse.getRules(1).getInternalKey()).isEqualTo("I002");
    assertThat(listResponse.getRules(1).getName()).isEqualTo("Rule Two");
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) Rules(org.sonarqube.ws.Rules) Test(org.junit.Test)

Example 62 with TestResponse

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

the class ResetActionTest method empty_204_response.

@Test
public void empty_204_response() {
    logInAsSystemAdministrator();
    TestResponse result = ws.newRequest().setParam("keys", "my.key").execute();
    assertThat(result.getStatus()).isEqualTo(HTTP_NO_CONTENT);
    assertThat(result.getInput()).isEmpty();
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) Test(org.junit.Test)

Example 63 with TestResponse

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

the class OrganizationActionTest method returns_non_admin_and_canDelete_false_when_user_not_logged_in_and_key_is_the_default_organization.

@Test
public void returns_non_admin_and_canDelete_false_when_user_not_logged_in_and_key_is_the_default_organization() {
    TestResponse response = executeRequest(dbTester.getDefaultOrganization());
    verifyResponse(response, false, false, false);
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) Test(org.junit.Test)

Example 64 with TestResponse

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

the class OrganizationActionTest method returns_only_canDelete_true_when_user_is_system_administrator_and_key_is_guarded_organization.

@Test
public void returns_only_canDelete_true_when_user_is_system_administrator_and_key_is_guarded_organization() {
    OrganizationDto organization = dbTester.organizations().insert(dto -> dto.setGuarded(true));
    userSession.logIn().setSystemAdministrator();
    TestResponse response = executeRequest(organization);
    verifyResponse(response, false, false, true);
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 65 with TestResponse

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

the class UploadActionTest method upload_plugin.

@Test
public void upload_plugin() throws Exception {
    logInAsSystemAdministrator();
    TestResponse response = call(newInputStream(plugin.toPath()), PLUGIN_NAME);
    assertThat(response.getStatus()).isEqualTo(204);
    assertPluginIsUploaded(PLUGIN_NAME);
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) Test(org.junit.Test)

Aggregations

TestResponse (org.sonar.server.ws.TestResponse)67 Test (org.junit.Test)64 OrganizationDto (org.sonar.db.organization.OrganizationDto)18 WsCe (org.sonarqube.ws.WsCe)13 ComponentDto (org.sonar.db.component.ComponentDto)9 CeActivityDto (org.sonar.db.ce.CeActivityDto)4 InputStream (java.io.InputStream)2 Date (java.util.Date)2 PermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateDto)2 UserDto (org.sonar.db.user.UserDto)2 ProjectRepositories (org.sonar.scanner.protocol.input.ProjectRepositories)2 File (java.io.File)1 IOException (java.io.IOException)1 LinkedHashMap (java.util.LinkedHashMap)1 CeQueueDto (org.sonar.db.ce.CeQueueDto)1 ComponentLinkDto (org.sonar.db.component.ComponentLinkDto)1 IssueDto (org.sonar.db.issue.IssueDto)1 PropertyDto (org.sonar.db.property.PropertyDto)1 RuleDto (org.sonar.db.rule.RuleDto)1 FileData (org.sonar.scanner.protocol.input.FileData)1