Package javax.validation.constraints

Examples of javax.validation.constraints.Pattern


  @Test
  @TestForIssue(jiraKey = "HV-502")
  public void testIsValidForCharSequence() {
    AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
    descriptor.setValue( "regexp", "char sequence" );
    Pattern p = AnnotationFactory.create( descriptor );

    PatternValidator constraint = new PatternValidator();
    constraint.initialize( p );

    assertTrue( constraint.isValid( new MyCustomStringImpl( "char sequence" ), null ) );
View Full Code Here


  @Test
  public void testIsValidForEmptyStringRegexp() {
    AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
    descriptor.setValue( "regexp", "|^.*foo$" );
    descriptor.setValue( "message", "pattern does not match" );
    Pattern p = AnnotationFactory.create( descriptor );

    PatternValidator constraint = new PatternValidator();
    constraint.initialize( p );

    assertTrue( constraint.isValid( null, null ) );
View Full Code Here

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testInvalidRegularExpression() {
    AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
    descriptor.setValue( "regexp", "(unbalanced parentheses" );
    descriptor.setValue( "message", "pattern does not match" );
    Pattern p = AnnotationFactory.create( descriptor );

    PatternValidator constraint = new PatternValidator();
    constraint.initialize( p );
  }
View Full Code Here

  @Test
  public void testIsValid() {
    AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
    descriptor.setValue( "regexp", "foobar" );
    descriptor.setValue( "message", "pattern does not match" );
    Pattern p = AnnotationFactory.create( descriptor );

    PatternValidator constraint = new PatternValidator();
    constraint.initialize( p );

    assertTrue( constraint.isValid( null, null ) );
View Full Code Here

  @Test
  public void createAnnotationProxyWithRequiredParameter() {
    AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
    descriptor.setValue( "regexp", ".*" );

    Pattern pattern = AnnotationFactory.create( descriptor );

    assertEquals( ".*", pattern.regexp(), "Wrong parameter value" );
  }
View Full Code Here

TOP

Related Classes of javax.validation.constraints.Pattern

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.