Package org.hibernate.validator.internal.engine.constraintvalidation

Examples of org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorContextImpl


    private ConstraintValidatorContext constraintValidatorContext;

    @Before
    public void setUp() {
        underTest = new UpdateStackRequestValidator();
        constraintValidatorContext = new ConstraintValidatorContextImpl(
                new ArrayList<String>(),
                PathImpl.createRootPath(),
                new DummyConstraintDescriptor()
                );
    }
View Full Code Here


                        new ParametersTypeValidator(),
                        new ParametersRegexValidator()
                        )
                );
        given(constraintValidatorContext.buildConstraintViolationWithTemplate(anyString())).willReturn(
                new ConstraintValidatorContextImpl(
                        new ArrayList<String>(),
                        PathImpl.createRootPath(),
                        new DummyConstraintDescriptor()
                ).buildConstraintViolationWithTemplate("dummytemplate")
                );
View Full Code Here

  private static String message = "message";

  @Test
  public void testIterableIndexed() {
    ConstraintValidatorContextImpl context = createEmptyConstraintValidatorContextImpl();
    context.buildConstraintViolationWithTemplate( message )
        .addPropertyNode( "foo" )
        .addPropertyNode( "bar" ).inIterable().atIndex( 3 )
        .addConstraintViolation();

    List<ConstraintViolationCreationContext> constraintViolationCreationContextList = context.getConstraintViolationCreationContexts();
    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message, "foo[3].bar" );
  }
View Full Code Here

    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message, "foo[3].bar" );
  }

  @Test
  public void testIterableKeyed() {
    ConstraintValidatorContextImpl context = createEmptyConstraintValidatorContextImpl();
    context.buildConstraintViolationWithTemplate( message )
        .addPropertyNode( "foo" )
        .addPropertyNode( null ).inIterable().atKey( "test" )
        .addConstraintViolation();

    List<ConstraintViolationCreationContext> constraintViolationCreationContextList = context.getConstraintViolationCreationContexts();
    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message, "foo[test]" );
  }
View Full Code Here

    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message, "foo[test]" );
  }

  @Test
  public void testIterableWithKeyFollowedBySimpleNodes() {
    ConstraintValidatorContextImpl context = createEmptyConstraintValidatorContextImpl();

    context.buildConstraintViolationWithTemplate( message )
        .addPropertyNode( "foo" )
        .addPropertyNode( "bar" ).inIterable().atKey( "test" )
        .addPropertyNode( "fubar" )
        .addConstraintViolation();

    List<ConstraintViolationCreationContext> constraintViolationCreationContextList = context.getConstraintViolationCreationContexts();
    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message, "foo[test].bar.fubar" );
  }
View Full Code Here

    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message, "foo[test].bar.fubar" );
  }

  @Test
  public void testIterableKeyedAndIndexed() {
    ConstraintValidatorContextImpl context = createEmptyConstraintValidatorContextImpl();
    context.buildConstraintViolationWithTemplate( message )
        .addPropertyNode( "foo" )
        .addPropertyNode( "bar" ).inIterable().atKey( "test" )
        .addPropertyNode( "fubar" ).inIterable().atIndex( 10 )
        .addConstraintViolation();

    List<ConstraintViolationCreationContext> constraintViolationCreationContextList = context.getConstraintViolationCreationContexts();
    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message, "foo[test].bar[10].fubar" );
  }
View Full Code Here

    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message, "foo[test].bar[10].fubar" );
  }

  @Test
  public void testMultipleInIterable() {
    ConstraintValidatorContextImpl context = createEmptyConstraintValidatorContextImpl();
    context.buildConstraintViolationWithTemplate( message )
        .addPropertyNode( "foo" )
        .addPropertyNode( "bar" ).inIterable().atKey( "test" )
        .addPropertyNode( "fubar" ).inIterable()
        .addConstraintViolation();

    List<ConstraintViolationCreationContext> constraintViolationCreationContextList = context.getConstraintViolationCreationContexts();
    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message, "foo[test].bar[].fubar" );
  }
View Full Code Here

    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message, "foo[test].bar[].fubar" );
  }

  @Test
  public void testMultipleSimpleNodes() {
    ConstraintValidatorContextImpl context = createEmptyConstraintValidatorContextImpl();
    context.buildConstraintViolationWithTemplate( message )
        .addPropertyNode( "foo" )
        .addPropertyNode( "bar" )
        .addPropertyNode( "test" )
        .addConstraintViolation();

    List<ConstraintViolationCreationContext> constraintViolationCreationContextList = context.getConstraintViolationCreationContexts();
    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message, "foo.bar.test" );
  }
View Full Code Here

    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message, "foo.bar.test" );
  }

  @Test
  public void testLongPath() {
    ConstraintValidatorContextImpl context = createEmptyConstraintValidatorContextImpl();
    context.buildConstraintViolationWithTemplate( message )
        .addPropertyNode( "a" )
        .addPropertyNode( "b" ).inIterable().atKey( "key1" )
        .addPropertyNode( "c" ).inIterable()
        .addPropertyNode( "d" )
        .addPropertyNode( "e" )
        .addPropertyNode( "f" ).inIterable().atKey( "key2" )
        .addConstraintViolation();

    List<ConstraintViolationCreationContext> constraintViolationCreationContextList = context.getConstraintViolationCreationContexts();
    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message, "a[key1].b[].c.d.e[key2].f" );
  }
View Full Code Here

  @Test
  public void testMultipleMessages() {
    String message1 = "message1";
    String message2 = "message2";
    ConstraintValidatorContextImpl context = createEmptyConstraintValidatorContextImpl();
    context.buildConstraintViolationWithTemplate( message1 )
        .addPropertyNode( "foo" )
        .addPropertyNode( "bar" ).inIterable().atKey( "key" )
        .addConstraintViolation();
    context.buildConstraintViolationWithTemplate( message2 )
        .addConstraintViolation();

    List<ConstraintViolationCreationContext> constraintViolationCreationContextList = context.getConstraintViolationCreationContexts();
    assertTrue( constraintViolationCreationContextList.size() == 2 );
    assertMessageAndPath( constraintViolationCreationContextList.get( 0 ), message1, "foo[key].bar" );
    assertMessageAndPath( constraintViolationCreationContextList.get( 1 ), message2, "" );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorContextImpl

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.