Skip to content

Commit

Permalink
Improve test readability
Browse files Browse the repository at this point in the history
  • Loading branch information
stijn-dejongh committed Sep 23, 2024
1 parent 63100f8 commit 373386c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
Expand Down Expand Up @@ -185,7 +185,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.10</version>
<version>0.8.12</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package be.sddevelopment.validation.specs.usage;

import be.sddevelopment.validation.core.Constraint;
import be.sddevelopment.validation.core.InvalidObjectException;
import be.sddevelopment.validation.core.ModularRuleset;
import be.sddevelopment.validation.core.*;
import org.assertj.core.api.WithAssertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
Expand Down Expand Up @@ -39,8 +37,12 @@ void modularValidatorsMustCoverBasicUsage_givenSimpleDateBasedValidationLogic()
.must(notBeNull)
.must(haveNonNullField(DateBasedDummyObject::localDate), "have a non-null local date")
.iHaveSpoken();
Constrained<DateBasedDummyObject> constrained = validator.constrain(toValidate);

assertThat(validator.constrain(toValidate)).is(valid());
assertThat(constrained).is(valid());
assertThat(constrained)
.extracting(Constrained::rationale)
.matches(Rationale::isPassing);
}

private record DateBasedDummyObject(LocalDate localDate) {
Expand Down Expand Up @@ -77,10 +79,10 @@ void checkedShouldAllowForFluentUsage_whenUsingItAsAGuard_givenInvalidObject() {

@Test
void allowsForFurtherProcessing() {
var toBeUsed = new DateBasedDummyObject("I have a name", LocalDate.of(2023, MARCH, 9));
var dateLoggingService = new DateLoggingService();
assertThat(requirements().constrain(toBeUsed)).is(valid());
assertThat(dateLoggingService.logLines()).isEmpty();
var toBeUsed = new DateBasedDummyObject("I have a name", LocalDate.of(2023, MARCH, 9));
assertThat(requirements().constrain(toBeUsed)).is(valid());

requirements().constrain(toBeUsed)
.extract(DateBasedDummyObject::localDate)
Expand Down

0 comments on commit 373386c

Please sign in to comment.