Skip to content

Commit

Permalink
Polish formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Jun 25, 2023
1 parent aecebf7 commit 6072a53
Showing 1 changed file with 51 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,26 @@ void validateArguments() {
assertThat(ex.getConstraintViolations()).hasSize(3);
assertThat(ex.getAllValidationResults()).hasSize(3);

assertBeanResult(ex.getBeanResults().get(0), 0, "student", faustino1234, List.of(
"""
Field error in object 'student' on field 'name': rejected value [Faustino1234]; \
codes [Size.student.name,Size.name,Size.java.lang.String,Size]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [student.name,name]; arguments []; default message [name],10,1]; \
default message [size must be between 1 and 10]"""));

assertBeanResult(ex.getBeanResults().get(1), 1, "guardian", cayetana6789, List.of(
"""
Field error in object 'guardian' on field 'name': rejected value [Cayetana6789]; \
codes [Size.guardian.name,Size.name,Size.java.lang.String,Size]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [guardian.name,name]; arguments []; default message [name],10,1]; \
default message [size must be between 1 and 10]"""));

assertValueResult(ex.getValueResults().get(0), 2, 3, List.of(
"""
org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [Max.myService#addStudent.degrees,Max.degrees,Max.int,Max]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [myService#addStudent.degrees,degrees]; arguments []; default message [degrees],2]; \
default message [must be less than or equal to 2]"""
));
assertBeanResult(ex.getBeanResults().get(0), 0, "student", faustino1234, List.of("""
Field error in object 'student' on field 'name': rejected value [Faustino1234]; \
codes [Size.student.name,Size.name,Size.java.lang.String,Size]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [student.name,name]; arguments []; default message [name],10,1]; \
default message [size must be between 1 and 10]"""));

assertBeanResult(ex.getBeanResults().get(1), 1, "guardian", cayetana6789, List.of("""
Field error in object 'guardian' on field 'name': rejected value [Cayetana6789]; \
codes [Size.guardian.name,Size.name,Size.java.lang.String,Size]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [guardian.name,name]; arguments []; default message [name],10,1]; \
default message [size must be between 1 and 10]"""));

assertValueResult(ex.getValueResults().get(0), 2, 3, List.of("""
org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [Max.myService#addStudent.degrees,Max.degrees,Max.int,Max]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [myService#addStudent.degrees,degrees]; arguments []; default message [degrees],2]; \
default message [must be less than or equal to 2]"""));
});
}

Expand All @@ -113,13 +109,12 @@ void validateArgumentWithCustomObjectName() {
assertThat(ex.getConstraintViolations()).hasSize(1);
assertThat(ex.getAllValidationResults()).hasSize(1);

assertBeanResult(ex.getBeanResults().get(0), 0, "studentToAdd", faustino1234, List.of(
"""
Field error in object 'studentToAdd' on field 'name': rejected value [Faustino1234]; \
codes [Size.studentToAdd.name,Size.name,Size.java.lang.String,Size]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [studentToAdd.name,name]; arguments []; default message [name],10,1]; \
default message [size must be between 1 and 10]"""));
assertBeanResult(ex.getBeanResults().get(0), 0, "studentToAdd", faustino1234, List.of("""
Field error in object 'studentToAdd' on field 'name': rejected value [Faustino1234]; \
codes [Size.studentToAdd.name,Size.name,Size.java.lang.String,Size]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [studentToAdd.name,name]; arguments []; default message [name],10,1]; \
default message [size must be between 1 and 10]"""));
});
}

Expand All @@ -132,14 +127,12 @@ void validateReturnValue() {
assertThat(ex.getConstraintViolations()).hasSize(1);
assertThat(ex.getAllValidationResults()).hasSize(1);

assertValueResult(ex.getValueResults().get(0), -1, 4, List.of(
"""
org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [Min.myService#getIntValue,Min,Min.int]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [myService#getIntValue]; arguments []; default message [],5]; \
default message [must be greater than or equal to 5]"""
));
assertValueResult(ex.getValueResults().get(0), -1, 4, List.of("""
org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [Min.myService#getIntValue,Min,Min.int]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [myService#getIntValue]; arguments []; default message [],5]; \
default message [must be greater than or equal to 5]"""));
});
}

Expand All @@ -152,13 +145,12 @@ void validateReturnValueBean() {
assertThat(ex.getConstraintViolations()).hasSize(1);
assertThat(ex.getAllValidationResults()).hasSize(1);

assertBeanResult(ex.getBeanResults().get(0), -1, "person", faustino1234, List.of(
"""
Field error in object 'person' on field 'name': rejected value [Faustino1234]; \
codes [Size.person.name,Size.name,Size.java.lang.String,Size]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [person.name,name]; arguments []; default message [name],10,1]; \
default message [size must be between 1 and 10]"""));
assertBeanResult(ex.getBeanResults().get(0), -1, "person", faustino1234, List.of("""
Field error in object 'person' on field 'name': rejected value [Faustino1234]; \
codes [Size.person.name,Size.name,Size.java.lang.String,Size]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [person.name,name]; arguments []; default message [name],10,1]; \
default message [size must be between 1 and 10]"""));
});
}

Expand All @@ -176,21 +168,19 @@ void validateListArgument() {
String objectName = "people";
List<ParameterErrors> results = ex.getBeanResults();

assertBeanResult(results.get(0), paramIndex, objectName, faustino1234, List.of(
"""
Field error in object 'people' on field 'name': rejected value [Faustino1234]; \
codes [Size.people.name,Size.name,Size.java.lang.String,Size]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [people.name,name]; arguments []; default message [name],10,1]; \
default message [size must be between 1 and 10]"""));

assertBeanResult(results.get(1), paramIndex, objectName, cayetana6789, List.of(
"""
Field error in object 'people' on field 'name': rejected value [Cayetana6789]; \
codes [Size.people.name,Size.name,Size.java.lang.String,Size]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [people.name,name]; arguments []; default message [name],10,1]; \
default message [size must be between 1 and 10]"""));
assertBeanResult(results.get(0), paramIndex, objectName, faustino1234, List.of("""
Field error in object 'people' on field 'name': rejected value [Faustino1234]; \
codes [Size.people.name,Size.name,Size.java.lang.String,Size]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [people.name,name]; arguments []; default message [name],10,1]; \
default message [size must be between 1 and 10]"""));

assertBeanResult(results.get(1), paramIndex, objectName, cayetana6789, List.of("""
Field error in object 'people' on field 'name': rejected value [Cayetana6789]; \
codes [Size.people.name,Size.name,Size.java.lang.String,Size]; \
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
codes [people.name,name]; arguments []; default message [name],10,1]; \
default message [size must be between 1 and 10]"""));
});
}

Expand Down

0 comments on commit 6072a53

Please sign in to comment.