Skip to content

Commit

Permalink
HV-1339 Making test more expressive in case of failures; using Option…
Browse files Browse the repository at this point in the history
…al with orElseGet()
  • Loading branch information
gunnarmorling committed May 17, 2017
1 parent 9f5983d commit e556093
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Expand Up @@ -86,14 +86,13 @@ private static <A extends Annotation> Type addValueExtractorDescriptorForWrapped

valueExtractionPath.add( TypeParameterAndExtractor.of( valueExtractorDescriptorCandidate ) );

if ( valueExtractorDescriptorCandidate.getExtractedType().isPresent() ) {
return valueExtractorDescriptorCandidate.getExtractedType().get();
}
else {
return getSingleTypeParameterBind( typeResolutionHelper,
location.getTypeForValidatorResolution(),
valueExtractorDescriptorCandidate.getContainerType() );
}
return valueExtractorDescriptorCandidate.getExtractedType()
.orElseGet( () ->
getSingleTypeParameterBind( typeResolutionHelper,
location.getTypeForValidatorResolution(),
valueExtractorDescriptorCandidate.getContainerType()
)
);
}
}

Expand Down
Expand Up @@ -46,16 +46,12 @@ public void testOptionalInt() {
assertNumberOfViolations( constraintViolations, 0 );

constraintViolations = validator.validate( Foo.invalid() );
assertNumberOfViolations( constraintViolations, 3 );
assertCorrectConstraintTypes( constraintViolations, Min.class, DecimalMin.class, Min.class );
assertThat( constraintViolations ).containsOnlyPaths(
pathWith()
.property( "optionalInt" ),
pathWith()
.property( "optionalDouble" ),
pathWith()
.property( "optionalLong" )
pathWith().property( "optionalInt" ),
pathWith().property( "optionalDouble" ),
pathWith().property( "optionalLong" )
);
assertCorrectConstraintTypes( constraintViolations, Min.class, DecimalMin.class, Min.class );
}

private static class Foo {
Expand Down

0 comments on commit e556093

Please sign in to comment.