|
23 | 23 |
|
24 | 24 | import java.lang.Thread.UncaughtExceptionHandler;
|
25 | 25 | import java.time.Duration;
|
| 26 | +import java.util.Collections; |
26 | 27 | import java.util.List;
|
| 28 | +import java.util.Optional; |
27 | 29 | import java.util.function.BiConsumer;
|
28 | 30 | import java.util.function.Consumer;
|
29 | 31 | import java.util.function.Function;
|
@@ -433,6 +435,57 @@ void failsAttachedEventConstraintsIfNoEventsPublished() {
|
433 | 435 | verify(runnable).run();
|
434 | 436 | }
|
435 | 437 |
|
| 438 | + @Test // GH-1131 |
| 439 | + void concludesForNonEmptyOptional() { |
| 440 | + |
| 441 | + givenAScenario(it -> it.publish(new Object()) |
| 442 | + .andWaitForStateChange(delayed(Optional.of("value")))) |
| 443 | + .expectSuccess(); |
| 444 | + } |
| 445 | + |
| 446 | + @Test // GH-1131 |
| 447 | + void doesNotConcludeForEmptyOptional() { |
| 448 | + |
| 449 | + givenAScenario(it -> it.publish(new Object()) |
| 450 | + .andWaitAtMost(Duration.ofMillis(500)) |
| 451 | + .andWaitForStateChange(delayed(Optional.empty()))) |
| 452 | + .expectFailure(); |
| 453 | + } |
| 454 | + |
| 455 | + @Test // GH-1131 |
| 456 | + void concludesForNonEmptyCollection() { |
| 457 | + |
| 458 | + givenAScenario(it -> it.publish(new Object()) |
| 459 | + .andWaitForStateChange(delayed(List.of("value")))) |
| 460 | + .expectSuccess(); |
| 461 | + } |
| 462 | + |
| 463 | + @Test // GH-1131 |
| 464 | + void doesNotConcludeForEmptyCollection() { |
| 465 | + |
| 466 | + givenAScenario(it -> it.publish(new Object()) |
| 467 | + .andWaitAtMost(Duration.ofMillis(500)) |
| 468 | + .andWaitForStateChange(delayed(Collections.emptyList()))) |
| 469 | + .expectFailure(); |
| 470 | + } |
| 471 | + |
| 472 | + @Test // GH-1131 |
| 473 | + void concludesForNonNull() { |
| 474 | + |
| 475 | + givenAScenario(it -> it.publish(new Object()) |
| 476 | + .andWaitForStateChange(delayed(new Object()))) |
| 477 | + .expectSuccess(); |
| 478 | + } |
| 479 | + |
| 480 | + @Test // GH-1131 |
| 481 | + void doesNotConcludeForNull() { |
| 482 | + |
| 483 | + givenAScenario(it -> it.publish(new Object()) |
| 484 | + .andWaitAtMost(Duration.ofMillis(500)) |
| 485 | + .andWaitForStateChange(delayed(null))) |
| 486 | + .expectFailure(); |
| 487 | + } |
| 488 | + |
436 | 489 | private Fixture givenAScenario(Consumer<Scenario> consumer) {
|
437 | 490 | return new Fixture(consumer, DELAY, null, new DefaultAssertablePublishedEvents());
|
438 | 491 | }
|
|
0 commit comments