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 @@ -144,15 +144,17 @@ void allOfWithEmptyPartsAlwaysPasses() {

@Test
void anyOfWithEmptyOptionsAlwaysFails() {
assertThatThrownBy(() -> v.validate("anything", new AnyOfSchema(List.of(), Map.of()), "/v"))
var schema = new AnyOfSchema(List.of(), Map.of());
assertThatThrownBy(() -> v.validate("anything", schema, "/v"))
.isInstanceOf(ValidationException.class)
.extracting(t -> ((ValidationException) t).error().keyword())
.isEqualTo("anyOf");
}

@Test
void oneOfWithEmptyOptionsAlwaysFails() {
assertThatThrownBy(() -> v.validate("anything", new OneOfSchema(List.of(), Map.of()), "/v"))
var schema = new OneOfSchema(List.of(), Map.of());
assertThatThrownBy(() -> v.validate("anything", schema, "/v"))
.isInstanceOf(ValidationException.class)
.satisfies(
t -> {
Expand All @@ -165,8 +167,8 @@ void oneOfWithEmptyOptionsAlwaysFails() {
@Test
void notWithNullSchemaRejectsNull() {
// not(NullSchema) — inner accepts null, outer must reject.
assertThatThrownBy(
() -> v.validate(null, new NotSchema(new NullSchema(Map.of()), Map.of()), "/v"))
var schema = new NotSchema(new NullSchema(Map.of()), Map.of());
assertThatThrownBy(() -> v.validate(null, schema, "/v"))
.isInstanceOf(ValidationException.class)
.extracting(t -> ((ValidationException) t).error().keyword())
.isEqualTo("not");
Expand Down Expand Up @@ -202,7 +204,8 @@ void alwaysSchemaAcceptsNull() {

@Test
void neverSchemaRejectsString() {
assertThatThrownBy(() -> v.validate("anything", new NeverSchema(Map.of()), "/v"))
var schema = new NeverSchema(Map.of());
assertThatThrownBy(() -> v.validate("anything", schema, "/v"))
.isInstanceOf(ValidationException.class)
.satisfies(
t -> {
Expand All @@ -217,15 +220,17 @@ void neverSchemaRejectsString() {
// Full ValidationError surface is verified by neverSchemaRejectsString; these cover keyword only.
@Test
void neverSchemaRejectsInteger() {
assertThatThrownBy(() -> v.validate(42, new NeverSchema(Map.of()), "/v"))
var schema = new NeverSchema(Map.of());
assertThatThrownBy(() -> v.validate(42, schema, "/v"))
.isInstanceOf(ValidationException.class)
.extracting(t -> ((ValidationException) t).error().keyword())
.isEqualTo("false");
}

@Test
void neverSchemaRejectsNull() {
assertThatThrownBy(() -> v.validate(null, new NeverSchema(Map.of()), "/v"))
var schema = new NeverSchema(Map.of());
assertThatThrownBy(() -> v.validate(null, schema, "/v"))
.isInstanceOf(ValidationException.class)
.extracting(t -> ((ValidationException) t).error().keyword())
.isEqualTo("false");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ void successfulAnyOfDoesNotConstructValidationException() {
@Test
void failingOneOfConstructsExactlyOneValidationException() {
long before = ValidationException.CONSTRUCTIONS.get();
var schema = stringOrNumber();

assertThatThrownBy(() -> validator.validate(true, stringOrNumber(), "/v"))
assertThatThrownBy(() -> validator.validate(true, schema, "/v"))
.isInstanceOf(ValidationException.class)
.extracting(t -> ((ValidationException) t).error().keyword())
.isEqualTo("oneOf");
Expand Down
Loading