Skip to content

Commit

Permalink
Simplify InjectValidatorFeatureTest
Browse files Browse the repository at this point in the history
  • Loading branch information
rhowe committed Feb 2, 2022
1 parent 815765c commit b2ec8c6
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void run(Configuration configuration, Environment environment) { }
private ValidatorFactory validatorFactory;

@BeforeEach
void setUp() throws Exception {
void setUp() {
Bootstrap<Configuration> bootstrap = new Bootstrap<>(application);
application.initialize(bootstrap);

Expand All @@ -57,14 +57,10 @@ void shouldValidateNormally() {
// Run validation manually
Set<ConstraintViolation<Bean>> constraintViolations = validator.validate(new Bean(1));


assertThat(constraintViolations.size()).isEqualTo(1);

Optional<String> message = constraintViolations.stream()
.findFirst()
.map(ConstraintViolation::getMessage);

assertThat(message).hasValue("must be greater than or equal to 10");
assertThat(constraintViolations)
.singleElement()
.extracting(ConstraintViolation::getMessage)
.isEqualTo("must be greater than or equal to 10");
}

@Test
Expand Down

0 comments on commit b2ec8c6

Please sign in to comment.