import static org.sonar.db.newcodeperiod.NewCodePeriodType.NUMBER_OF_DAYS;
import static org.sonar.db.newcodeperiod.NewCodePeriodType.REFERENCE_BRANCH;
import static org.sonar.server.almintegration.ws.ImportHelper.PARAM_ALM_SETTING;
-import static org.sonar.server.almintegration.ws.github.ImportGithubProjectAction.PARAM_ORGANIZATION;
import static org.sonar.server.almintegration.ws.github.ImportGithubProjectAction.PARAM_REPOSITORY_KEY;
import static org.sonar.server.tester.UserSessionRule.standalone;
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_NEW_CODE_DEFINITION_TYPE;
Projects.CreateWsResponse response = ws.newRequest()
.setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey())
- .setParam(PARAM_ORGANIZATION, "octocat")
.setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME)
.setParam(PARAM_NEW_CODE_DEFINITION_TYPE, "NUMBER_OF_DAYS")
.setParam(PARAM_NEW_CODE_DEFINITION_VALUE, "30")
Projects.CreateWsResponse response = ws.newRequest()
.setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey())
- .setParam(PARAM_ORGANIZATION, "octocat")
.setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME)
.setParam(PARAM_NEW_CODE_DEFINITION_TYPE, "NUMBER_OF_DAYS")
.setParam(PARAM_NEW_CODE_DEFINITION_VALUE, "30")
Projects.CreateWsResponse response = ws.newRequest()
.setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey())
- .setParam(PARAM_ORGANIZATION, "octocat")
.setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME)
.setParam(PARAM_NEW_CODE_DEFINITION_TYPE, "reference_branch")
.executeProtobuf(Projects.CreateWsResponse.class);
Projects.CreateWsResponse response = ws.newRequest()
.setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey())
- .setParam(PARAM_ORGANIZATION, "octocat")
.setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME)
.setParam(PARAM_NEW_CODE_DEFINITION_TYPE, "reference_branch")
.executeProtobuf(Projects.CreateWsResponse.class);
Projects.CreateWsResponse response = ws.newRequest()
.setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey())
- .setParam(PARAM_ORGANIZATION, "octocat")
.setParam(PARAM_REPOSITORY_KEY, "Hello-World")
.executeProtobuf(Projects.CreateWsResponse.class);
ws.newRequest()
.setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey())
- .setParam(PARAM_ORGANIZATION, "octocat")
.setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME)
.executeProtobuf(Projects.CreateWsResponse.class);
ws.newRequest()
.setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey())
- .setParam(PARAM_ORGANIZATION, "octocat")
.setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME)
.executeProtobuf(Projects.CreateWsResponse.class);
TestRequest request = ws.newRequest()
.setParam(PARAM_ALM_SETTING, "unknown")
- .setParam(PARAM_ORGANIZATION, "test")
.setParam(PARAM_REPOSITORY_KEY, "test/repo");
assertThatThrownBy(request::execute)
.isInstanceOf(NotFoundException.class)
userSession.logIn(user).addPermission(GlobalPermission.PROVISION_PROJECTS);
TestRequest request = ws.newRequest()
- .setParam(PARAM_ORGANIZATION, "test")
.setParam(PARAM_REPOSITORY_KEY, "test/repo");
assertThatThrownBy(request::execute)
.isInstanceOf(NotFoundException.class)
db.almSettings().insertGitHubAlmSetting();
TestRequest request = ws.newRequest()
- .setParam(PARAM_ORGANIZATION, "test")
.setParam(PARAM_REPOSITORY_KEY, "test/repo");
assertThatThrownBy(request::execute)
.isInstanceOf(IllegalArgumentException.class)
TestRequest request = ws.newRequest()
.setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey())
- .setParam(PARAM_ORGANIZATION, "octocat")
.setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME);
assertThatNoException().isThrownBy(request::execute);
private Projects.CreateWsResponse callWebService(AlmSettingDto githubAlmSetting) {
return ws.newRequest()
.setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey())
- .setParam(PARAM_ORGANIZATION, "octocat")
.setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME)
.executeProtobuf(Projects.CreateWsResponse.class);
}
public void fail_when_not_logged_in() {
TestRequest request = ws.newRequest()
.setParam(PARAM_ALM_SETTING, "asdfghjkl")
- .setParam(PARAM_ORGANIZATION, "test")
.setParam(PARAM_REPOSITORY_KEY, "test/repo");
assertThatThrownBy(request::execute)
.isInstanceOf(UnauthorizedException.class);
TestRequest request = ws.newRequest()
.setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey())
- .setParam(PARAM_ORGANIZATION, "test")
.setParam(PARAM_REPOSITORY_KEY, "test/repo");
assertThatThrownBy(request::execute)
.isInstanceOf(IllegalArgumentException.class)
.extracting(WebService.Param::key, WebService.Param::isRequired)
.containsExactlyInAnyOrder(
tuple(PARAM_ALM_SETTING, false),
- tuple(PARAM_ORGANIZATION, true),
tuple(PARAM_REPOSITORY_KEY, true),
tuple(PARAM_NEW_CODE_DEFINITION_TYPE, false),
tuple(PARAM_NEW_CODE_DEFINITION_VALUE, false));