|
13 | 13 | import static com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.syntacticsugar.Sugar.*;
|
14 | 14 | import static com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.syntacticsugar.TimeMachine.assumeThat;
|
15 | 15 | import static com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.syntacticsugar.TimeMachine.currentTime;
|
16 |
| -import static hudson.model.Result.ABORTED; |
17 |
| -import static hudson.model.Result.FAILURE; |
18 |
| -import static hudson.model.Result.SUCCESS; |
19 |
| -import static hudson.model.Result.UNSTABLE; |
20 |
| -import static org.hamcrest.CoreMatchers.hasItems; |
21 |
| -import static org.hamcrest.CoreMatchers.not; |
| 16 | +import static hudson.model.Result.*; |
22 | 17 | import static org.hamcrest.Matchers.contains;
|
23 | 18 | import static org.hamcrest.Matchers.containsString;
|
24 |
| -import static org.hamcrest.Matchers.hasItem; |
25 |
| -import static org.hamcrest.collection.IsCollectionWithSize.hasSize; |
26 | 19 | import static org.hamcrest.core.Is.is;
|
27 | 20 | import static org.junit.Assert.assertThat;
|
28 |
| -import static org.mockito.Mockito.mock; |
29 |
| -import static org.mockito.Mockito.times; |
30 |
| -import static org.mockito.Mockito.verify; |
31 |
| -import static org.mockito.Mockito.when; |
| 21 | +import static org.mockito.Mockito.*; |
32 | 22 |
|
33 | 23 | /**
|
34 | 24 | * @author Jan Molak
|
@@ -347,77 +337,53 @@ public void should_describe_the_job_as_claimed_if_someone_claimed_last_build_fai
|
347 | 337 | }
|
348 | 338 |
|
349 | 339 | /*
|
350 |
| - * Should know who broke the build |
| 340 | + * Executive summary |
351 | 341 | */
|
352 | 342 |
|
353 | 343 | @Test
|
354 |
| - public void should_know_who_broke_the_build() { |
| 344 | + public void should_tell_who_broke_the_build() throws Exception { |
355 | 345 | view = a(jobView().of(
|
356 |
| - a(job().whereTheLast(build().wasBrokenBy("Adam", "Ben"))))); |
357 |
| - |
358 |
| - assertThat(view.culprits(), hasSize(2)); |
359 |
| - assertThat(view.culprits(), hasItems("Adam", "Ben")); |
360 |
| - } |
361 |
| - |
362 |
| - @Test |
363 |
| - public void should_know_who_has_been_committing_over_broken_build() { |
364 |
| - view = a(jobView().of( |
365 |
| - a(job().whereTheLast(build().wasBrokenBy("Adam")). |
366 |
| - andThePrevious(build().wasBrokenBy("Ben", "Connor")). |
367 |
| - andThePrevious(build().wasBrokenBy("Daniel")). |
368 |
| - andThePrevious(build().succeededThanksTo("Errol"))))); |
369 |
| - |
370 |
| - assertThat(view.culprits(), hasSize(4)); |
371 |
| - assertThat(view.culprits(), hasItems("Adam", "Ben", "Connor", "Daniel")); |
372 |
| - assertThat(view.culprits(), not(hasItem("Errol"))); |
373 |
| - } |
374 |
| - |
375 |
| - @Test |
376 |
| - public void should_only_mention_each_culprit_once() { |
377 |
| - view = a(jobView().of( |
378 |
| - a(job().whereTheLast(build().wasBrokenBy("Adam")). |
379 |
| - andThePrevious(build().wasBrokenBy("Adam", "Ben")). |
380 |
| - andThePrevious(build().wasBrokenBy("Ben", "Connor"))))); |
| 346 | + a(job().whereTheLast(build().wasBrokenBy("Adam"))))); |
381 | 347 |
|
382 |
| - assertThat(view.culprits(), hasSize(3)); |
383 |
| - assertThat(view.culprits(), hasItems("Adam", "Ben", "Connor")); |
| 348 | + assertThat(view.headline(), is("Failed after Adam committed their changes")); |
384 | 349 | }
|
385 | 350 |
|
386 | 351 | @Test
|
387 |
| - public void should_not_mention_any_culprits_if_the_build_was_successful() { |
| 352 | + public void should_list_committers_who_broke_the_build() throws Exception { |
388 | 353 | view = a(jobView().of(
|
389 |
| - a(job().whereTheLast(build().succeededThanksTo("Adam"))))); |
| 354 | + a(job().whereTheLast(build().wasBrokenBy("Adam", "Ben"))))); |
390 | 355 |
|
391 |
| - assertThat(view.culprits(), hasSize(0)); |
| 356 | + assertThat(view.headline(), is("Failed after Ben and Adam committed their changes")); |
392 | 357 | }
|
393 | 358 |
|
394 | 359 | @Test
|
395 |
| - public void should_not_mention_any_culprits_if_the_build_was_successful_and_is_still_running() { |
| 360 | + public void should_tell_who_broke_the_previous_build_if_the_current_one_is_still_running() throws Exception { |
396 | 361 | view = a(jobView().of(
|
397 |
| - a(job().whereTheLast(build().isStillBuilding()) |
398 |
| - .andThePrevious(build().succeededThanksTo("Adam"))))); |
| 362 | + a(job().whereTheLast(build().isStillBuilding()). |
| 363 | + andThePrevious(build().wasBrokenBy("Ben"))))); |
399 | 364 |
|
400 |
| - assertThat(view.culprits(), hasSize(0)); |
| 365 | + assertThat(view.headline(), is("Failed after Ben committed their changes")); |
401 | 366 | }
|
402 | 367 |
|
403 | 368 | @Test
|
404 |
| - public void should_indicate_culprits_if_the_build_is_failing_and_not_claimed() { |
| 369 | + public void should_tell_the_number_of_broken_builds_since_the_last_broken_build() throws Exception { |
405 | 370 | view = a(jobView().of(
|
406 |
| - a(job().whereTheLast(build().wasBrokenBy("Adam")))) |
407 |
| - .augmented(with(Claim.class))); |
| 371 | + a(job().whereTheLast(build().wasBrokenBy("Adam")). |
| 372 | + andThePrevious(build().wasBrokenBy("Ben", "Connor")). |
| 373 | + andThePrevious(build().wasBrokenBy("Daniel")). |
| 374 | + andThePrevious(build().succeededThanksTo("Errol"))))); |
408 | 375 |
|
409 |
| - assertThat(view.shouldIndicateCulprits(), is(true)); |
410 |
| - assertThat(view.culprits(), hasSize(1)); |
| 376 | + assertThat(view.headline(), is("2 builds have failed since Daniel committed their changes")); |
411 | 377 | }
|
412 | 378 |
|
413 | 379 | @Test
|
414 |
| - public void should_not_indicate_any_culprits_if_the_build_was_failing_but_is_now_claimed() { |
| 380 | + public void should_tell_the_number_of_broken_builds_since_the_last_build_broken_by_multiple_committers() throws Exception { |
415 | 381 | view = a(jobView().of(
|
416 |
| - a(job().whereTheLast(build().wasBrokenBy("Adam").and().wasClaimedBy("Ben", "Helping out Adam")))) |
417 |
| - .augmented(with(Claim.class))); |
| 382 | + a(job().whereTheLast(build().wasBrokenBy("Adam")). |
| 383 | + andThePrevious(build().wasBrokenBy("Ben", "Connor")). |
| 384 | + andThePrevious(build().succeededThanksTo("Daniel"))))); |
418 | 385 |
|
419 |
| - assertThat(view.shouldIndicateCulprits(), is(false)); |
420 |
| - assertThat(view.culprits(), hasSize(1)); |
| 386 | + assertThat(view.headline(), is("1 build has failed since Ben and Connor committed their changes")); |
421 | 387 | }
|
422 | 388 |
|
423 | 389 | /*
|
@@ -457,11 +423,10 @@ public void public_api_should_return_reasonable_defaults_for_jobs_that_never_run
|
457 | 423 |
|
458 | 424 | assertThat(view.lastBuildName(), is(""));
|
459 | 425 | assertThat(view.lastBuildUrl(), is(""));
|
| 426 | + assertThat(view.headline(), is("")); |
460 | 427 | assertThat(view.lastBuildDuration(), is(""));
|
461 | 428 | assertThat(view.estimatedDuration(), is(""));
|
462 | 429 | assertThat(view.progress(), is(0));
|
463 |
| - assertThat(view.shouldIndicateCulprits(), is(false)); |
464 |
| - assertThat(view.culprits(), hasSize(0)); |
465 | 430 | assertThat(view.status(), is("unknown"));
|
466 | 431 | assertThat(view.isClaimed(), is(false));
|
467 | 432 | assertThat(view.hasKnownFailures(), is(false));
|
|
0 commit comments