You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AlmSettingsTesting.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2020 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.db.almsettings;
  21. import org.sonar.db.alm.setting.ALM;
  22. import org.sonar.db.alm.setting.AlmSettingDto;
  23. import org.sonar.db.alm.setting.ProjectAlmSettingDto;
  24. import org.sonar.db.project.ProjectDto;
  25. import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
  26. public class AlmSettingsTesting {
  27. public static AlmSettingDto newGithubAlmSettingDto() {
  28. return new AlmSettingDto()
  29. .setKey(randomAlphanumeric(200))
  30. .setUrl(randomAlphanumeric(2000))
  31. .setAppId(randomAlphanumeric(80))
  32. .setPrivateKey(randomAlphanumeric(2000))
  33. .setAlm(ALM.GITHUB);
  34. }
  35. public static AlmSettingDto newAzureAlmSettingDto() {
  36. return new AlmSettingDto()
  37. .setKey(randomAlphanumeric(200))
  38. .setPersonalAccessToken(randomAlphanumeric(2000))
  39. .setAlm(ALM.AZURE_DEVOPS);
  40. }
  41. public static AlmSettingDto newGitlabAlmSettingDto() {
  42. return new AlmSettingDto()
  43. .setKey(randomAlphanumeric(200))
  44. .setPersonalAccessToken(randomAlphanumeric(2000))
  45. .setUrl(randomAlphanumeric(2000))
  46. .setAlm(ALM.GITLAB);
  47. }
  48. public static AlmSettingDto newBitbucketAlmSettingDto() {
  49. return new AlmSettingDto()
  50. .setKey(randomAlphanumeric(200))
  51. .setUrl(randomAlphanumeric(2000))
  52. .setPersonalAccessToken(randomAlphanumeric(2000))
  53. .setAlm(ALM.BITBUCKET);
  54. }
  55. public static ProjectAlmSettingDto newGithubProjectAlmSettingDto(AlmSettingDto githubAlmSetting, ProjectDto project) {
  56. return new ProjectAlmSettingDto()
  57. .setAlmSettingUuid(githubAlmSetting.getUuid())
  58. .setProjectUuid(project.getUuid())
  59. .setAlmRepo(randomAlphanumeric(256))
  60. .setSummaryCommentEnabled(true);
  61. }
  62. static ProjectAlmSettingDto newGitlabProjectAlmSettingDto(AlmSettingDto gitlabAlmSetting, ProjectDto project) {
  63. return new ProjectAlmSettingDto()
  64. .setAlmSettingUuid(gitlabAlmSetting.getUuid())
  65. .setProjectUuid(project.getUuid());
  66. }
  67. static ProjectAlmSettingDto newAzureProjectAlmSettingDto(AlmSettingDto azureAlmSetting, ProjectDto project) {
  68. return new ProjectAlmSettingDto()
  69. .setAlmSettingUuid(azureAlmSetting.getUuid())
  70. .setProjectUuid(project.getUuid());
  71. }
  72. public static ProjectAlmSettingDto newBitbucketProjectAlmSettingDto(AlmSettingDto githubAlmSetting, ProjectDto project) {
  73. return new ProjectAlmSettingDto()
  74. .setAlmSettingUuid(githubAlmSetting.getUuid())
  75. .setProjectUuid(project.getUuid())
  76. .setAlmRepo(randomAlphanumeric(256))
  77. .setAlmSlug(randomAlphanumeric(256));
  78. }
  79. }