|
6 | 6 | import static org.hamcrest.Matchers.anEmptyMap;
|
7 | 7 | import static org.hamcrest.Matchers.arrayWithSize;
|
8 | 8 | import static org.hamcrest.Matchers.contains;
|
9 |
| -import static org.hamcrest.Matchers.containsInAnyOrder; |
10 | 9 | import static org.hamcrest.Matchers.containsString;
|
11 | 10 | import static org.hamcrest.Matchers.empty;
|
12 | 11 | import static org.hamcrest.Matchers.emptyArray;
|
@@ -453,20 +452,40 @@ public void getBuildTargets_onlyBuildOnComment_multiple_comments_generate_multip
|
453 | 452 | when(stashApiClient.getPullRequestComments(any(), any(), any())).thenReturn(comments);
|
454 | 453 | when(trigger.getCiBuildPhrases()).thenReturn("DO TEST");
|
455 | 454 | when(trigger.getOnlyBuildOnComment()).thenReturn(true);
|
| 455 | + when(trigger.getCancelOutdatedJobsEnabled()).thenReturn(false); |
456 | 456 |
|
457 |
| - Collection<StashPullRequestBuildTarget> buildTargets = |
458 |
| - stashRepository.getBuildTargets(pullRequest); |
| 457 | + List<StashPullRequestBuildTarget> buildTargets = stashRepository.getBuildTargets(pullRequest); |
459 | 458 |
|
460 | 459 | assertThat(buildTargets, hasSize(2));
|
461 | 460 | assertThat(
|
462 |
| - buildTargets, |
463 |
| - containsInAnyOrder( |
464 |
| - allOf( |
465 |
| - hasProperty("additionalParameters", aMapWithSize(2)), |
466 |
| - hasProperty( |
467 |
| - "additionalParameters", |
468 |
| - allOf(hasEntry("key1", "value1"), hasEntry("key2", "value2")))), |
469 |
| - hasProperty("additionalParameters", anEmptyMap()))); |
| 461 | + buildTargets.get(0), |
| 462 | + allOf( |
| 463 | + hasProperty("additionalParameters", aMapWithSize(2)), |
| 464 | + hasProperty( |
| 465 | + "additionalParameters", |
| 466 | + allOf(hasEntry("key1", "value1"), hasEntry("key2", "value2"))))); |
| 467 | + assertThat(buildTargets.get(1), hasProperty("additionalParameters", anEmptyMap())); |
| 468 | + } |
| 469 | + |
| 470 | + @Test |
| 471 | + public void |
| 472 | + getBuildTargets_onlyBuildOnComment_cancelOutdatedJobsDisabled_generates_targets_in_comment_id_order() |
| 473 | + throws Exception { |
| 474 | + StashPullRequestComment comment1 = new StashPullRequestComment(1, "DO TEST\np:key1=value1"); |
| 475 | + StashPullRequestComment comment2 = new StashPullRequestComment(2, "DO TEST\np:key2=value2"); |
| 476 | + List<StashPullRequestComment> comments = Arrays.asList(comment2, comment1); |
| 477 | + when(stashApiClient.getPullRequestComments(any(), any(), any())).thenReturn(comments); |
| 478 | + when(trigger.getCiBuildPhrases()).thenReturn("DO TEST"); |
| 479 | + when(trigger.getOnlyBuildOnComment()).thenReturn(true); |
| 480 | + when(trigger.getCancelOutdatedJobsEnabled()).thenReturn(false); |
| 481 | + |
| 482 | + List<StashPullRequestBuildTarget> buildTargets = stashRepository.getBuildTargets(pullRequest); |
| 483 | + |
| 484 | + assertThat(buildTargets, hasSize(2)); |
| 485 | + assertThat( |
| 486 | + buildTargets.get(0), hasProperty("additionalParameters", hasEntry("key1", "value1"))); |
| 487 | + assertThat( |
| 488 | + buildTargets.get(1), hasProperty("additionalParameters", hasEntry("key2", "value2"))); |
470 | 489 | }
|
471 | 490 |
|
472 | 491 | @Test
|
|
0 commit comments