Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@SuppressWarnings("unchecked")
@Slf4j
public abstract class ModifyableTestDataCreator<CREATOR extends ModifyableTestDataCreator<CREATOR, ITEM, PARAMETER>, ITEM, PARAMETER> extends TestDataCreator<ITEM> {
public abstract class ModifiableTestDataCreator<CREATOR extends ModifiableTestDataCreator<CREATOR, ITEM, PARAMETER>, ITEM, PARAMETER> extends TestDataCreator<ITEM> {
protected static final FakerExtended FAKER = new FakerExtended();

private boolean mutatorSet = false;
Expand All @@ -25,7 +25,7 @@ public abstract class ModifyableTestDataCreator<CREATOR extends ModifyableTestDa
protected ObjIntConsumer<ITEM> resultMutator = (item, index) -> {
};

protected ModifyableTestDataCreator(int count) {
protected ModifiableTestDataCreator(int count) {
super(count);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,19 @@ private static <P> void assertThatValidationIsCompliantForEachProperty(
var violations = validator.validate(copy);

// Check if there are any violations
var violatingFieldMessages = violations
.stream()
.map(violation ->
"%s => %s".formatted(
violation.getPropertyPath().toString(),
violation.getMessage()
)
);

assertThat(violations)
.withFailMessage(
"More than one property failed to validate during mutation. The supplied parameter possibly contains invalid values."
"More than one property failed to validate during mutation. The supplied parameter possibly contains invalid values: %s",
violatingFieldMessages.collect(Collectors.joining(" | "))
)
.hasSizeLessThan(2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import it.aboutbits.springboot.testing.validation.core.Rule;
import it.aboutbits.springboot.testing.validation.core.ValidationRulesData;
import it.aboutbits.springboot.testing.validation.source.BlankValueSource;
import it.aboutbits.springboot.testing.validation.source.NullValueSource;
import lombok.NonNull;

@SuppressWarnings("unchecked")
Expand All @@ -12,6 +13,9 @@ default V notBlank(@NonNull String property) {
addRule(
new Rule(property, BlankValueSource.class)
);
addRule(
new Rule(property, NullValueSource.class)
);
return (V) this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import it.aboutbits.springboot.testing.validation.core.Rule;
import it.aboutbits.springboot.testing.validation.core.ValidationRulesData;
import it.aboutbits.springboot.testing.validation.source.EmptyValueSource;
import it.aboutbits.springboot.testing.validation.source.NullValueSource;
import lombok.NonNull;

@SuppressWarnings("unchecked")
Expand All @@ -12,6 +13,9 @@ default V notEmpty(@NonNull String property) {
addRule(
new Rule(property, EmptyValueSource.class)
);
addRule(
new Rule(property, NullValueSource.class)
);
return (V) this;
}
}