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");
}
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();
}
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);
}
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);
}
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);
}
Aggregations