|
1 | 1 | package be.sddevelopment.validation.specs.usage;
|
2 | 2 |
|
3 |
| -import be.sddevelopment.validation.core.Constraint; |
4 |
| -import be.sddevelopment.validation.core.InvalidObjectException; |
5 |
| -import be.sddevelopment.validation.core.ModularRuleset; |
| 3 | +import be.sddevelopment.validation.core.*; |
6 | 4 | import org.assertj.core.api.WithAssertions;
|
7 | 5 | import org.junit.jupiter.api.DisplayName;
|
8 | 6 | import org.junit.jupiter.api.Nested;
|
@@ -39,8 +37,12 @@ void modularValidatorsMustCoverBasicUsage_givenSimpleDateBasedValidationLogic()
|
39 | 37 | .must(notBeNull)
|
40 | 38 | .must(haveNonNullField(DateBasedDummyObject::localDate), "have a non-null local date")
|
41 | 39 | .iHaveSpoken();
|
| 40 | + Constrained<DateBasedDummyObject> constrained = validator.constrain(toValidate); |
42 | 41 |
|
43 |
| - assertThat(validator.constrain(toValidate)).is(valid()); |
| 42 | + assertThat(constrained).is(valid()); |
| 43 | + assertThat(constrained) |
| 44 | + .extracting(Constrained::rationale) |
| 45 | + .matches(Rationale::isPassing); |
44 | 46 | }
|
45 | 47 |
|
46 | 48 | private record DateBasedDummyObject(LocalDate localDate) {
|
@@ -77,10 +79,10 @@ void checkedShouldAllowForFluentUsage_whenUsingItAsAGuard_givenInvalidObject() {
|
77 | 79 |
|
78 | 80 | @Test
|
79 | 81 | void allowsForFurtherProcessing() {
|
80 |
| - var toBeUsed = new DateBasedDummyObject("I have a name", LocalDate.of(2023, MARCH, 9)); |
81 | 82 | var dateLoggingService = new DateLoggingService();
|
82 |
| - assertThat(requirements().constrain(toBeUsed)).is(valid()); |
83 | 83 | assertThat(dateLoggingService.logLines()).isEmpty();
|
| 84 | + var toBeUsed = new DateBasedDummyObject("I have a name", LocalDate.of(2023, MARCH, 9)); |
| 85 | + assertThat(requirements().constrain(toBeUsed)).is(valid()); |
84 | 86 |
|
85 | 87 | requirements().constrain(toBeUsed)
|
86 | 88 | .extract(DateBasedDummyObject::localDate)
|
|
0 commit comments