"Requires the 'Create Projects' permission")
.setPost(false)
.setSince("8.6")
+ .setResponseExample(getClass().getResource("example-list_azure_projects.json"))
.setHandler(this);
action.createParam(PARAM_ALM_SETTING)
"Requires the 'Create Projects' permission")
.setPost(false)
.setSince("8.6")
+ .setResponseExample(getClass().getResource("example-search_azure_repos.json"))
.setHandler(this);
action.createParam(PARAM_ALM_SETTING)
"Requires the 'Create Projects' permission")
.setPost(false)
.setSince("9.0")
+ .setResponseExample(getClass().getResource("example-search_bitbucketcloud_repos.json"))
.setHandler(this);
action.createParam(PARAM_ALM_SETTING)
"Requires the 'Create Projects' permission")
.setPost(false)
.setSince("8.2")
+ .setResponseExample(getClass().getResource("example-list_bitbucketserver_projects.json"))
.setHandler(this);
action.createParam(PARAM_ALM_SETTING)
"Requires the 'Create Projects' permission")
.setPost(false)
.setSince("8.2")
+ .setResponseExample(getClass().getResource("example-search_bitbucketserver_repos.json"))
.setHandler(this);
action.createParam(PARAM_ALM_SETTING)
--- /dev/null
+{
+ "projects": [
+ {
+ "name": "project1",
+ "description": "description1"
+ },
+ {
+ "name": "project2",
+ "description": "description2"
+ }
+ ]
+}
--- /dev/null
+{
+ "repositories": [
+ {
+ "name": "repoName1",
+ "projectName": "project1"
+ },
+ {
+ "name": "repoName2",
+ "projectName": "project2"
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+{
+ "paging": {
+ "pageIndex": 1,
+ "pageSize": 100
+ },
+ "isLastPage": false,
+ "repositories": [
+ {
+ "slug": "repo-slug-1",
+ "uuid": "REPO-UUID-ONE",
+ "name": "repoName1",
+ "projectKey": "projectKey1",
+ "workspace": "60Mna3eiSKjB2JqXucUVXoQMQbl2q0mTxJ2fyR0xfRuAcibVepy7yEfptuuFM3kd3f9v7eKtoT3JPd01"
+ },
+ {
+ "slug": "repo-slug-2",
+ "uuid": "REPO-UUID-TWO",
+ "name": "repoName2",
+ "sqProjectKey": "KEY_01814E2745E7D394BD",
+ "projectKey": "projectKey2",
+ "workspace": "60Mna3eiSKjB2JqXucUVXoQMQbl2q0mTxJ2fyR0xfRuAcibVepy7yEfptuuFM3kd3f9v7eKtoT3JPd01"
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+{
+ "projects": [
+ {
+ "key": "key",
+ "name": "name"
+ },
+ {
+ "key": "key2",
+ "name": "name2"
+ }
+ ]
+}
--- /dev/null
+{
+ "isLastPage": false,
+ "repositories": [
+ {
+ "slug": "repo-slug-1",
+ "uuid": "REPO-UUID-ONE",
+ "name": "repoName1",
+ "projectKey": "projectKey1",
+ "workspace": "60Mna3eiSKjB2JqXucUVXoQMQbl2q0mTxJ2fyR0xfRuAcibVepy7yEfptuuFM3kd3f9v7eKtoT3JPd01"
+ },
+ {
+ "slug": "repo-slug-2",
+ "uuid": "REPO-UUID-TWO",
+ "name": "repoName2",
+ "sqProjectKey": "KEY_01814E2745E7D394BD",
+ "projectKey": "projectKey2",
+ "workspace": "60Mna3eiSKjB2JqXucUVXoQMQbl2q0mTxJ2fyR0xfRuAcibVepy7yEfptuuFM3kd3f9v7eKtoT3JPd01"
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+{
+ "canBeExported": true,
+ "canBeImported": false,
+ "exportedDump": "/data/governance/export/my_project.zip",
+ "dumpToImport": "/data/governance/import/my_project.zip"
+}
assertThat(def.since()).isEqualTo("8.6");
assertThat(def.isPost()).isFalse();
+ assertThat(def.responseExampleFormat()).isEqualTo("json");
assertThat(def.params())
.extracting(WebService.Param::key, WebService.Param::isRequired)
.containsExactlyInAnyOrder(tuple("almSetting", true));
assertThat(def.since()).isEqualTo("8.6");
assertThat(def.isPost()).isFalse();
+ assertThat(def.responseExampleFormat()).isEqualTo("json");
assertThat(def.params())
.extracting(WebService.Param::key, WebService.Param::isRequired)
.containsExactlyInAnyOrder(
assertThat(def.since()).isEqualTo("9.0");
assertThat(def.isPost()).isFalse();
+ assertThat(def.responseExampleFormat()).isEqualTo("json");
assertThat(def.params())
.extracting(WebService.Param::key, WebService.Param::isRequired)
.containsExactlyInAnyOrder(
private Repository getBBCRepo2() {
Project project2 = new Project("PROJECT-UUID-TWO", "projectKey2", "projectName2");
- Repository repo2 = new Repository("REPO-UUID-TWO", "repo-slug-2", "repoName2", project2, null);
- return repo2;
+ return new Repository("REPO-UUID-TWO", "repo-slug-2", "repoName2", project2, null);
}
}
assertThat(def.since()).isEqualTo("8.2");
assertThat(def.isPost()).isFalse();
+ assertThat(def.responseExampleFormat()).isEqualTo("json");
assertThat(def.params())
.extracting(WebService.Param::key, WebService.Param::isRequired)
.containsExactlyInAnyOrder(tuple("almSetting", true));
assertThat(def.since()).isEqualTo("8.2");
assertThat(def.isPost()).isFalse();
+ assertThat(def.responseExampleFormat()).isEqualTo("json");
assertThat(def.params())
.extracting(WebService.Param::key, WebService.Param::isRequired)
.containsExactlyInAnyOrder(
import org.sonar.alm.client.github.security.UserAccessToken;
import org.sonar.api.config.internal.Encryption;
import org.sonar.api.config.internal.Settings;
+import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
import org.sonar.db.alm.pat.AlmPatDto;
.isEqualTo(pat.getPersonalAccessToken());
}
+ @Test
+ public void definition() {
+ WebService.Action def = ws.getDef();
+
+ assertThat(def.since()).isEqualTo("8.4");
+ assertThat(def.isPost()).isFalse();
+ assertThat(def.isInternal()).isTrue();
+ assertThat(def.responseExampleFormat()).isEqualTo("json");
+ assertThat(def.params())
+ .extracting(WebService.Param::key, WebService.Param::isRequired)
+ .containsExactlyInAnyOrder(tuple("p", false), tuple("ps", false), tuple("almSetting", true), tuple("token", false));
+ }
+
private void setupGhOrganizations(AlmSettingDto almSetting, String pat) {
when(appClient.listOrganizations(eq(almSetting.getUrl()), argThat(token -> token.getValue().equals(pat)), eq(1), eq(100)))
.thenReturn(new GithubApplicationClient.Organizations()
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.config.Configuration;
+import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.System2;
import org.sonar.api.web.UserRole;
import org.sonar.core.util.Slug;
import static java.util.Comparator.reverseOrder;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.tuple;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.sonar.api.resources.Qualifiers.PROJECT;
cleanUpFilesystem();
}
+ @Test
+ public void definition() {
+ WebService.Action definition = underTest.getDef();
+
+ assertThat(definition.key()).isEqualTo("status");
+ assertThat(definition.isPost()).isFalse();
+ assertThat(definition.description()).isNotEmpty();
+ assertThat(definition.since()).isEqualTo("1.0");
+ assertThat(definition.isInternal()).isTrue();
+ assertThat(definition.responseExampleFormat()).isEqualTo("json");
+ assertThat(definition.params())
+ .extracting(WebService.Param::key, WebService.Param::isRequired)
+ .containsExactlyInAnyOrder(
+ tuple("id", false),
+ tuple("key", false));
+ }
+
@Test
public void fails_with_BRE_if_no_param_is_provided() {
assertThatThrownBy(() -> underTest.newRequest().execute())