]> source.dussan.org Git - sonarqube.git/blob
3c9c3338e67ce82ed68be81b8b9038f1beb851e5
[sonarqube.git] /
1 /*
2  * SonarQube
3  * Copyright (C) 2009-2023 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.server.almintegration.ws.azure;
21
22 import java.util.Optional;
23 import org.junit.Before;
24 import org.junit.Rule;
25 import org.junit.Test;
26 import org.sonar.alm.client.azure.AzureDevOpsHttpClient;
27 import org.sonar.alm.client.azure.GsonAzureProject;
28 import org.sonar.alm.client.azure.GsonAzureRepo;
29 import org.sonar.api.config.internal.Encryption;
30 import org.sonar.api.server.ws.WebService;
31 import org.sonar.api.utils.System2;
32 import org.sonar.core.platform.EditionProvider;
33 import org.sonar.core.platform.PlatformEditionProvider;
34 import org.sonar.core.util.SequenceUuidFactory;
35 import org.sonar.db.DbTester;
36 import org.sonar.db.alm.pat.AlmPatDto;
37 import org.sonar.db.alm.setting.AlmSettingDto;
38 import org.sonar.db.alm.setting.ProjectAlmSettingDto;
39 import org.sonar.db.component.BranchDto;
40 import org.sonar.db.newcodeperiod.NewCodePeriodDto;
41 import org.sonar.db.project.ProjectDto;
42 import org.sonar.db.user.UserDto;
43 import org.sonar.server.almintegration.ws.ImportHelper;
44 import org.sonar.server.almintegration.ws.ProjectKeyGenerator;
45 import org.sonar.server.component.ComponentUpdater;
46 import org.sonar.server.es.TestIndexers;
47 import org.sonar.server.exceptions.BadRequestException;
48 import org.sonar.server.exceptions.ForbiddenException;
49 import org.sonar.server.exceptions.NotFoundException;
50 import org.sonar.server.exceptions.UnauthorizedException;
51 import org.sonar.server.favorite.FavoriteUpdater;
52 import org.sonar.server.l18n.I18nRule;
53 import org.sonar.server.newcodeperiod.NewCodeDefinitionResolver;
54 import org.sonar.server.permission.PermissionTemplateService;
55 import org.sonar.server.project.DefaultBranchNameResolver;
56 import org.sonar.server.project.ProjectDefaultVisibility;
57 import org.sonar.server.project.Visibility;
58 import org.sonar.server.tester.UserSessionRule;
59 import org.sonar.server.ws.TestRequest;
60 import org.sonar.server.ws.WsActionTester;
61 import org.sonarqube.ws.Projects;
62
63 import static org.assertj.core.api.Assertions.assertThat;
64 import static org.assertj.core.api.Assertions.assertThatThrownBy;
65 import static org.assertj.core.api.Assertions.tuple;
66 import static org.mockito.ArgumentMatchers.any;
67 import static org.mockito.Mockito.mock;
68 import static org.mockito.Mockito.verify;
69 import static org.mockito.Mockito.when;
70 import static org.sonar.db.alm.integration.pat.AlmPatsTesting.newAlmPatDto;
71 import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
72 import static org.sonar.db.newcodeperiod.NewCodePeriodType.NUMBER_OF_DAYS;
73 import static org.sonar.db.newcodeperiod.NewCodePeriodType.REFERENCE_BRANCH;
74 import static org.sonar.db.permission.GlobalPermission.PROVISION_PROJECTS;
75 import static org.sonar.db.permission.GlobalPermission.SCAN;
76 import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_NEW_CODE_DEFINITION_TYPE;
77 import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_NEW_CODE_DEFINITION_VALUE;
78
79 public class ImportAzureProjectActionIT {
80
81   private static final String GENERATED_PROJECT_KEY = "TEST_PROJECT_KEY";
82
83   @Rule
84   public UserSessionRule userSession = UserSessionRule.standalone();
85   @Rule
86   public DbTester db = DbTester.create();
87   @Rule
88   public final I18nRule i18n = new I18nRule();
89
90   private final AzureDevOpsHttpClient azureDevOpsHttpClient = mock(AzureDevOpsHttpClient.class);
91
92   private final DefaultBranchNameResolver defaultBranchNameResolver = mock(DefaultBranchNameResolver.class);
93
94   private final ComponentUpdater componentUpdater = new ComponentUpdater(db.getDbClient(), i18n, System2.INSTANCE,
95     mock(PermissionTemplateService.class), new FavoriteUpdater(db.getDbClient()), new TestIndexers(), new SequenceUuidFactory(),
96     defaultBranchNameResolver, true);
97
98   private final Encryption encryption = mock(Encryption.class);
99   private final ImportHelper importHelper = new ImportHelper(db.getDbClient(), userSession);
100   private final ProjectDefaultVisibility projectDefaultVisibility = mock(ProjectDefaultVisibility.class);
101   private final ProjectKeyGenerator projectKeyGenerator = mock(ProjectKeyGenerator.class);
102
103   private PlatformEditionProvider editionProvider = mock(PlatformEditionProvider.class);
104   private NewCodeDefinitionResolver newCodeDefinitionResolver = new NewCodeDefinitionResolver(db.getDbClient(), editionProvider);
105   private final ImportAzureProjectAction importAzureProjectAction = new ImportAzureProjectAction(db.getDbClient(), userSession,
106     azureDevOpsHttpClient, projectDefaultVisibility, componentUpdater, importHelper, projectKeyGenerator, newCodeDefinitionResolver,
107     defaultBranchNameResolver);
108   private final WsActionTester ws = new WsActionTester(importAzureProjectAction);
109
110   @Before
111   public void before() {
112     when(projectDefaultVisibility.get(any())).thenReturn(Visibility.PRIVATE);
113     when(projectKeyGenerator.generateUniqueProjectKey(any(), any())).thenReturn(GENERATED_PROJECT_KEY);
114     when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_MAIN_BRANCH_NAME);
115   }
116
117   @Test
118   public void import_project() {
119     UserDto user = db.users().insertUser();
120     userSession.logIn(user).addPermission(PROVISION_PROJECTS);
121     AlmSettingDto almSetting = db.almSettings().insertAzureAlmSetting();
122     db.almPats().insert(dto -> {
123       dto.setAlmSettingUuid(almSetting.getUuid());
124       dto.setPersonalAccessToken(almSetting.getDecryptedPersonalAccessToken(encryption));
125       dto.setUserUuid(user.getUuid());
126     });
127     GsonAzureRepo repo = getGsonAzureRepo();
128     when(azureDevOpsHttpClient.getRepo(almSetting.getUrl(), almSetting.getDecryptedPersonalAccessToken(encryption),
129       "project-name", "repo-name"))
130       .thenReturn(repo);
131
132     Projects.CreateWsResponse response = ws.newRequest()
133       .setParam("almSetting", almSetting.getKey())
134       .setParam("projectName", "project-name")
135       .setParam("repositoryName", "repo-name")
136       .executeProtobuf(Projects.CreateWsResponse.class);
137
138     Projects.CreateWsResponse.Project result = response.getProject();
139     assertThat(result.getKey()).isEqualTo(GENERATED_PROJECT_KEY);
140     assertThat(result.getName()).isEqualTo(repo.getName());
141
142     Optional<ProjectDto> projectDto = db.getDbClient().projectDao().selectProjectByKey(db.getSession(), result.getKey());
143     assertThat(projectDto).isPresent();
144
145     Optional<ProjectAlmSettingDto> projectAlmSettingDto = db.getDbClient().projectAlmSettingDao().selectByProject(db.getSession(),
146       projectDto.get());
147     assertThat(projectAlmSettingDto.get().getAlmRepo()).isEqualTo("repo-name");
148     assertThat(projectAlmSettingDto.get().getAlmSettingUuid()).isEqualTo(almSetting.getUuid());
149     assertThat(projectAlmSettingDto.get().getAlmSlug()).isEqualTo("project-name");
150
151     Optional<BranchDto> mainBranch = db.getDbClient()
152       .branchDao()
153       .selectByProject(db.getSession(), projectDto.get())
154       .stream()
155       .filter(BranchDto::isMain)
156       .findFirst();
157     assertThat(mainBranch).isPresent();
158     assertThat(mainBranch.get().getKey()).hasToString("repo-default-branch");
159
160     verify(projectKeyGenerator).generateUniqueProjectKey(repo.getProject().getName(), repo.getName());
161   }
162
163   @Test
164   public void import_project_with_NCD_developer_edition() {
165     when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.DEVELOPER));
166
167     UserDto user = db.users().insertUser();
168     userSession.logIn(user).addPermission(PROVISION_PROJECTS);
169     AlmSettingDto almSetting = db.almSettings().insertAzureAlmSetting();
170     db.almPats().insert(dto -> {
171       dto.setAlmSettingUuid(almSetting.getUuid());
172       dto.setPersonalAccessToken(almSetting.getDecryptedPersonalAccessToken(encryption));
173       dto.setUserUuid(user.getUuid());
174     });
175     GsonAzureRepo repo = getGsonAzureRepo();
176     when(azureDevOpsHttpClient.getRepo(almSetting.getUrl(), almSetting.getDecryptedPersonalAccessToken(encryption),
177       "project-name", "repo-name"))
178       .thenReturn(repo);
179
180     Projects.CreateWsResponse response = ws.newRequest()
181       .setParam("almSetting", almSetting.getKey())
182       .setParam("projectName", "project-name")
183       .setParam("repositoryName", "repo-name")
184       .setParam(PARAM_NEW_CODE_DEFINITION_TYPE, "NUMBER_OF_DAYS")
185       .setParam(PARAM_NEW_CODE_DEFINITION_VALUE, "30")
186       .executeProtobuf(Projects.CreateWsResponse.class);
187
188     Projects.CreateWsResponse.Project result = response.getProject();
189
190     Optional<ProjectDto> projectDto = db.getDbClient().projectDao().selectProjectByKey(db.getSession(), result.getKey());
191     assertThat(projectDto).isPresent();
192
193     assertThat(db.getDbClient().newCodePeriodDao().selectByProject(db.getSession(), projectDto.get().getUuid()))
194       .isPresent()
195       .get()
196       .extracting(NewCodePeriodDto::getType, NewCodePeriodDto::getValue, NewCodePeriodDto::getBranchUuid)
197       .containsExactly(NUMBER_OF_DAYS, "30", null);
198   }
199
200   @Test
201   public void import_project_with_NCD_community_edition() {
202     when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.COMMUNITY));
203
204     UserDto user = db.users().insertUser();
205     userSession.logIn(user).addPermission(PROVISION_PROJECTS);
206     AlmSettingDto almSetting = db.almSettings().insertAzureAlmSetting();
207     db.almPats().insert(dto -> {
208       dto.setAlmSettingUuid(almSetting.getUuid());
209       dto.setPersonalAccessToken(almSetting.getDecryptedPersonalAccessToken(encryption));
210       dto.setUserUuid(user.getUuid());
211     });
212     GsonAzureRepo repo = getGsonAzureRepo();
213     when(azureDevOpsHttpClient.getRepo(almSetting.getUrl(), almSetting.getDecryptedPersonalAccessToken(encryption),
214       "project-name", "repo-name"))
215       .thenReturn(repo);
216
217     Projects.CreateWsResponse response = ws.newRequest()
218       .setParam("almSetting", almSetting.getKey())
219       .setParam("projectName", "project-name")
220       .setParam("repositoryName", "repo-name")
221       .setParam(PARAM_NEW_CODE_DEFINITION_TYPE, "NUMBER_OF_DAYS")
222       .setParam(PARAM_NEW_CODE_DEFINITION_VALUE, "30")
223       .executeProtobuf(Projects.CreateWsResponse.class);
224
225     Projects.CreateWsResponse.Project result = response.getProject();
226
227     Optional<ProjectDto> projectDto = db.getDbClient().projectDao().selectProjectByKey(db.getSession(), result.getKey());
228     BranchDto branchDto = db.getDbClient().branchDao().selectMainBranchByProjectUuid(db.getSession(), projectDto.get().getUuid()).orElseThrow();
229     assertThat(projectDto).isPresent();
230
231     String projectUuid = projectDto.get().getUuid();
232     assertThat(db.getDbClient().newCodePeriodDao().selectByBranch(db.getSession(), projectUuid, branchDto.getUuid()))
233       .isPresent()
234       .get()
235       .extracting(NewCodePeriodDto::getType, NewCodePeriodDto::getValue, NewCodePeriodDto::getBranchUuid)
236       .containsExactly(NUMBER_OF_DAYS, "30", branchDto.getUuid());
237   }
238
239   @Test
240   public void import_project_throw_IAE_when_newCodeDefinitionValue_provided_and_no_newCodeDefinitionType() {
241     when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.DEVELOPER));
242
243     UserDto user = db.users().insertUser();
244     userSession.logIn(user).addPermission(PROVISION_PROJECTS);
245     AlmSettingDto almSetting = db.almSettings().insertAzureAlmSetting();
246     db.almPats().insert(dto -> {
247       dto.setAlmSettingUuid(almSetting.getUuid());
248       dto.setPersonalAccessToken(almSetting.getDecryptedPersonalAccessToken(encryption));
249       dto.setUserUuid(user.getUuid());
250     });
251     GsonAzureRepo repo = getGsonAzureRepo();
252     when(azureDevOpsHttpClient.getRepo(almSetting.getUrl(), almSetting.getDecryptedPersonalAccessToken(encryption),
253       "project-name", "repo-name"))
254       .thenReturn(repo);
255
256     Projects.CreateWsResponse response = ws.newRequest()
257       .setParam("almSetting", almSetting.getKey())
258       .setParam("projectName", "project-name")
259       .setParam("repositoryName", "repo-name")
260       .setParam(PARAM_NEW_CODE_DEFINITION_TYPE, "NUMBER_OF_DAYS")
261       .setParam(PARAM_NEW_CODE_DEFINITION_VALUE, "30")
262       .executeProtobuf(Projects.CreateWsResponse.class);
263
264     Projects.CreateWsResponse.Project result = response.getProject();
265
266     Optional<ProjectDto> projectDto = db.getDbClient().projectDao().selectProjectByKey(db.getSession(), result.getKey());
267     assertThat(projectDto).isPresent();
268
269     assertThat(db.getDbClient().newCodePeriodDao().selectByProject(db.getSession(), projectDto.get().getUuid()))
270       .isPresent()
271       .get()
272       .extracting(NewCodePeriodDto::getType, NewCodePeriodDto::getValue, NewCodePeriodDto::getBranchUuid)
273       .containsExactly(NUMBER_OF_DAYS, "30", null);
274   }
275
276   @Test
277   public void import_project_reference_branch_ncd_no_default_branch_name() {
278     when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.DEVELOPER));
279
280     UserDto user = db.users().insertUser();
281     userSession.logIn(user).addPermission(PROVISION_PROJECTS);
282     AlmSettingDto almSetting = db.almSettings().insertAzureAlmSetting();
283     db.almPats().insert(dto -> {
284       dto.setAlmSettingUuid(almSetting.getUuid());
285       dto.setPersonalAccessToken(almSetting.getDecryptedPersonalAccessToken(encryption));
286       dto.setUserUuid(user.getUuid());
287     });
288     GsonAzureRepo repo = getEmptyGsonAzureRepo();
289     when(azureDevOpsHttpClient.getRepo(almSetting.getUrl(), almSetting.getDecryptedPersonalAccessToken(encryption),
290       "project-name", "repo-name"))
291       .thenReturn(repo);
292
293     Projects.CreateWsResponse response = ws.newRequest()
294       .setParam("almSetting", almSetting.getKey())
295       .setParam("projectName", "project-name")
296       .setParam("repositoryName", "repo-name")
297       .setParam(PARAM_NEW_CODE_DEFINITION_TYPE, "REFERENCE_BRANCH")
298       .executeProtobuf(Projects.CreateWsResponse.class);
299
300     Projects.CreateWsResponse.Project result = response.getProject();
301
302     Optional<ProjectDto> projectDto = db.getDbClient().projectDao().selectProjectByKey(db.getSession(), result.getKey());
303     assertThat(projectDto).isPresent();
304
305     assertThat(db.getDbClient().newCodePeriodDao().selectByProject(db.getSession(), projectDto.get().getUuid()))
306       .isPresent()
307       .get()
308       .extracting(NewCodePeriodDto::getType, NewCodePeriodDto::getValue)
309       .containsExactly(REFERENCE_BRANCH, DEFAULT_MAIN_BRANCH_NAME);
310   }
311
312   @Test
313   public void import_project_reference_branch_ncd() {
314     when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.DEVELOPER));
315
316     UserDto user = db.users().insertUser();
317     userSession.logIn(user).addPermission(PROVISION_PROJECTS);
318     AlmSettingDto almSetting = db.almSettings().insertAzureAlmSetting();
319     db.almPats().insert(dto -> {
320       dto.setAlmSettingUuid(almSetting.getUuid());
321       dto.setPersonalAccessToken(almSetting.getDecryptedPersonalAccessToken(encryption));
322       dto.setUserUuid(user.getUuid());
323     });
324     GsonAzureRepo repo = getGsonAzureRepo();
325     when(azureDevOpsHttpClient.getRepo(almSetting.getUrl(), almSetting.getDecryptedPersonalAccessToken(encryption),
326       "project-name", "repo-name"))
327       .thenReturn(repo);
328
329     Projects.CreateWsResponse response = ws.newRequest()
330       .setParam("almSetting", almSetting.getKey())
331       .setParam("projectName", "project-name")
332       .setParam("repositoryName", "repo-name")
333       .setParam(PARAM_NEW_CODE_DEFINITION_TYPE, "REFERENCE_BRANCH")
334       .executeProtobuf(Projects.CreateWsResponse.class);
335
336     Projects.CreateWsResponse.Project result = response.getProject();
337
338     Optional<ProjectDto> projectDto = db.getDbClient().projectDao().selectProjectByKey(db.getSession(), result.getKey());
339     assertThat(projectDto).isPresent();
340
341     assertThat(db.getDbClient().newCodePeriodDao().selectByProject(db.getSession(), projectDto.get().getUuid()))
342       .isPresent()
343       .get()
344       .extracting(NewCodePeriodDto::getType, NewCodePeriodDto::getValue)
345       .containsExactly(REFERENCE_BRANCH, "repo-default-branch");
346   }
347
348   @Test
349   public void import_project_from_empty_repo() {
350     UserDto user = db.users().insertUser();
351     userSession.logIn(user).addPermission(PROVISION_PROJECTS);
352     AlmSettingDto almSetting = db.almSettings().insertAzureAlmSetting();
353     db.almPats().insert(dto -> {
354       dto.setAlmSettingUuid(almSetting.getUuid());
355       dto.setPersonalAccessToken(almSetting.getDecryptedPersonalAccessToken(encryption));
356       dto.setUserUuid(user.getUuid());
357     });
358     GsonAzureRepo repo = getEmptyGsonAzureRepo();
359     when(azureDevOpsHttpClient.getRepo(almSetting.getUrl(), almSetting.getDecryptedPersonalAccessToken(encryption),
360       "project-name", "repo-name"))
361       .thenReturn(repo);
362
363     TestRequest request = ws.newRequest()
364       .setParam("almSetting", almSetting.getKey())
365       .setParam("projectName", "project-name")
366       .setParam("repositoryName", "repo-name")
367       .setParam(PARAM_NEW_CODE_DEFINITION_VALUE, "30");
368
369     assertThatThrownBy(() -> request.executeProtobuf(Projects.CreateWsResponse.class))
370       .isInstanceOf(IllegalArgumentException.class)
371       .hasMessage("New code definition type is required when new code definition value is provided");
372   }
373
374   @Test
375   public void fail_when_not_logged_in() {
376     TestRequest request = ws.newRequest()
377       .setParam("almSetting", "azure")
378       .setParam("projectName", "project-name")
379       .setParam("repositoryName", "repo-name");
380
381     assertThatThrownBy(request::execute)
382       .isInstanceOf(UnauthorizedException.class);
383   }
384
385   @Test
386   public void fail_when_missing_project_creator_permission() {
387     UserDto user = db.users().insertUser();
388     userSession.logIn(user).addPermission(SCAN);
389
390     TestRequest request = ws.newRequest()
391       .setParam("almSetting", "azure")
392       .setParam("projectName", "project-name")
393       .setParam("repositoryName", "repo-name");
394
395     assertThatThrownBy(request::execute)
396       .isInstanceOf(ForbiddenException.class)
397       .hasMessage("Insufficient privileges");
398   }
399
400   @Test
401   public void check_pat_is_missing() {
402     UserDto user = db.users().insertUser();
403     userSession.logIn(user).addPermission(PROVISION_PROJECTS);
404     AlmSettingDto almSetting = db.almSettings().insertAzureAlmSetting();
405
406     TestRequest request = ws.newRequest()
407       .setParam("almSetting", almSetting.getKey())
408       .setParam("projectName", "project-name")
409       .setParam("repositoryName", "repo-name");
410
411     assertThatThrownBy(request::execute)
412       .isInstanceOf(IllegalArgumentException.class)
413       .hasMessage("personal access token for '" + almSetting.getKey() + "' is missing");
414   }
415
416   @Test
417   public void fail_check_alm_setting_not_found() {
418     UserDto user = db.users().insertUser();
419     userSession.logIn(user).addPermission(PROVISION_PROJECTS);
420     AlmPatDto almPatDto = newAlmPatDto();
421     db.getDbClient().almPatDao().insert(db.getSession(), almPatDto, user.getLogin(), null);
422
423     TestRequest request = ws.newRequest()
424       .setParam("almSetting", "testKey");
425
426     assertThatThrownBy(request::execute)
427       .isInstanceOf(NotFoundException.class)
428       .hasMessage("DevOps Platform Setting 'testKey' not found");
429   }
430
431   @Test
432   public void fail_project_already_exists() {
433     UserDto user = db.users().insertUser();
434     userSession.logIn(user).addPermission(PROVISION_PROJECTS);
435     AlmSettingDto almSetting = db.almSettings().insertAzureAlmSetting();
436     db.almPats().insert(dto -> {
437       dto.setAlmSettingUuid(almSetting.getUuid());
438       dto.setPersonalAccessToken(almSetting.getDecryptedPersonalAccessToken(encryption));
439       dto.setUserUuid(user.getUuid());
440     });
441     GsonAzureRepo repo = getGsonAzureRepo();
442     db.components().insertPublicProject(p -> p.setKey(GENERATED_PROJECT_KEY)).getMainBranchComponent();
443
444     when(azureDevOpsHttpClient.getRepo(almSetting.getUrl(), almSetting.getDecryptedPersonalAccessToken(encryption),
445       "project-name", "repo-name")).thenReturn(repo);
446     TestRequest request = ws.newRequest()
447       .setParam("almSetting", almSetting.getKey())
448       .setParam("projectName", "project-name")
449       .setParam("repositoryName", "repo-name");
450
451     assertThatThrownBy(request::execute)
452       .isInstanceOf(BadRequestException.class)
453       .hasMessage("Could not create Project with key: \"%s\". A similar key already exists: \"%s\"", GENERATED_PROJECT_KEY,
454         GENERATED_PROJECT_KEY);
455   }
456
457   @Test
458   public void define() {
459     WebService.Action def = ws.getDef();
460
461     assertThat(def.since()).isEqualTo("8.6");
462     assertThat(def.isPost()).isTrue();
463     assertThat(def.params())
464       .extracting(WebService.Param::key, WebService.Param::isRequired)
465       .containsExactlyInAnyOrder(
466         tuple("almSetting", true),
467         tuple("projectName", true),
468         tuple("repositoryName", true),
469         tuple(PARAM_NEW_CODE_DEFINITION_TYPE, false),
470         tuple(PARAM_NEW_CODE_DEFINITION_VALUE, false));
471   }
472
473   private GsonAzureRepo getGsonAzureRepo() {
474     return new GsonAzureRepo("repo-id", "repo-name", "repo-url",
475       new GsonAzureProject("project-name", "project-description"),
476       "refs/heads/repo-default-branch");
477   }
478
479   private GsonAzureRepo getEmptyGsonAzureRepo() {
480     return new GsonAzureRepo("repo-id", "repo-name", "repo-url",
481       new GsonAzureProject("project-name", "project-description"), null);
482   }
483
484 }