### Question:
MinValidatorForNumber implements ConstraintValidator<Min, Number> { public void initialize(Min minValue) { this.minValue = minValue.value(); }  void initialize(Min minValue); boolean isValid(Number value, ConstraintValidatorContext constraintValidatorContext);  }### Answer:
@Test public void testIsValidMinValidator() { AnnotationDescriptor<Min> descriptor = new AnnotationDescriptor<Min>( Min.class ); descriptor.setValue( "value", 15l ); descriptor.setValue( "message", "{validator.min}" ); Min m = AnnotationFactory.create( descriptor ); MinValidatorForNumber constraint = new MinValidatorForNumber(); constraint.initialize( m ); testMinValidator( constraint ); }
@Test public void testIsValidDecimalMinValidator() { AnnotationDescriptor<DecimalMin> descriptor = new AnnotationDescriptor<DecimalMin>( DecimalMin.class ); descriptor.setValue( "value", "1500E-2" ); descriptor.setValue( "message", "{validator.min}" ); DecimalMin m = AnnotationFactory.create( descriptor ); DecimalMinValidatorForNumber constraint = new DecimalMinValidatorForNumber(); constraint.initialize( m ); testMinValidator( constraint ); }
@Test public void testInitializeDecimalMaxWithInvalidValue() { AnnotationDescriptor<DecimalMin> descriptor = new AnnotationDescriptor<DecimalMin>( DecimalMin.class ); descriptor.setValue( "value", "foobar" ); descriptor.setValue( "message", "{validator.min}" ); DecimalMin m = AnnotationFactory.create( descriptor ); DecimalMinValidatorForNumber constraint = new DecimalMinValidatorForNumber(); try { constraint.initialize( m ); fail(); } catch ( IllegalArgumentException e ) { } }
@Test public void testInitializeDecimalMaxWithInvalidValue() { AnnotationDescriptor<DecimalMin> descriptor = new AnnotationDescriptor<DecimalMin>( DecimalMin.class ); descriptor.setValue( "value", "foobar" ); descriptor.setValue( "message", "{validator.min}" ); DecimalMin m = AnnotationFactory.create( descriptor ); DecimalMinValidatorForNumber constraint = new DecimalMinValidatorForNumber(); try { constraint.initialize( m ); fail(); } catch ( ConstraintDeclarationException e ) { } }