Package javax.validation

Examples of javax.validation.MessageInterpolator.interpolate()


    MessageInterpolator interpolator = getDefaultMessageInterpolator();
    ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" );
    MessageInterpolator.Context context = new TestContext( descriptor );

    String expected = "{bar}"// unknown token {}
    String actual = interpolator.interpolate( "{bar}", context );
    assertEquals( actual, expected, "Wrong substitution" );
  }

  @Test
  @SpecAssertion(section = "5.3.1.1", id = "c")
View Full Code Here


    MessageInterpolator interpolator = getDefaultMessageInterpolator();
    ConstraintDescriptor<?> descriptor = getDescriptorFor( Person.class, "birthday" );
    MessageInterpolator.Context context = new TestContext( descriptor );

    String key = "{javax.validation.constraints.Past.message}"; // Past is a built-in constraint so the provider must provide a default message
    String actual = interpolator.interpolate( key, context );
    assertFalse(
        key.equals( actual ),
        "There should have been a message interpolation from the bean validator provider bundle."
    );
  }
View Full Code Here

    MessageInterpolator interpolator = getDefaultMessageInterpolator();
    ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "bar" );
    MessageInterpolator.Context context = new TestContext( descriptor );

    String expected = "size must be between 5 and 10";
    String actual = interpolator.interpolate( (String) descriptor.getAttributes().get( "message" ), context );
    assertEquals( actual, expected, "Wrong substitution" );
  }

  @Test
  @SpecAssertion(section = "5.3.1.1", id = "f")
View Full Code Here

    ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "amount" );
    MessageInterpolator.Context context = new TestContext( descriptor );

    //if EL evaluation kicked in first, the "$" would be gone
    String expected = "must be $5 at least";
    String actual = interpolator.interpolate( (String) descriptor.getAttributes().get( "message" ), context );
    assertEquals( actual, expected, "Wrong substitution" );
  }

  @Test
  @SpecAssertion(section = "5.3.1.1", id = "g")
View Full Code Here

    MessageInterpolator interpolator = getDefaultMessageInterpolator();
    ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" );
    MessageInterpolator.Context context = new TestContext( descriptor );

    String expected = "replacement worked";
    String actual = interpolator.interpolate( "{foo}", context );
    assertEquals( actual, expected, "Wrong substitution" );

    expected = "replacement worked replacement worked";
    actual = interpolator.interpolate( "{foo} {foo}", context );
    assertEquals( actual, expected, "Wrong substitution" );
View Full Code Here

    String expected = "replacement worked";
    String actual = interpolator.interpolate( "{foo}", context );
    assertEquals( actual, expected, "Wrong substitution" );

    expected = "replacement worked replacement worked";
    actual = interpolator.interpolate( "{foo} {foo}", context );
    assertEquals( actual, expected, "Wrong substitution" );

    expected = "This replacement worked just fine";
    actual = interpolator.interpolate( "This {foo} just fine", context );
    assertEquals( actual, expected, "Wrong substitution" );
View Full Code Here

    expected = "replacement worked replacement worked";
    actual = interpolator.interpolate( "{foo} {foo}", context );
    assertEquals( actual, expected, "Wrong substitution" );

    expected = "This replacement worked just fine";
    actual = interpolator.interpolate( "This {foo} just fine", context );
    assertEquals( actual, expected, "Wrong substitution" );

    expected = "{} replacement worked {unknown}";
    actual = interpolator.interpolate( "{} {foo} {unknown}", context );
    assertEquals( actual, expected, "Wrong substitution" );
View Full Code Here

    expected = "This replacement worked just fine";
    actual = interpolator.interpolate( "This {foo} just fine", context );
    assertEquals( actual, expected, "Wrong substitution" );

    expected = "{} replacement worked {unknown}";
    actual = interpolator.interpolate( "{} {foo} {unknown}", context );
    assertEquals( actual, expected, "Wrong substitution" );
  }

  @Test
  @SpecAssertion(section = "4.3.1.1", id = "b")
View Full Code Here

    MessageInterpolator interpolator = getDefaultMessageInterpolator();
    ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "fubar" );
    MessageInterpolator.Context context = new TestContext( descriptor );

    String expected = "recursion worked";
    String actual = interpolator.interpolate( ( String ) descriptor.getAttributes().get( "message" ), context );
    assertEquals(
        expected, actual, "Expansion should be recursive"
    );
  }
View Full Code Here

    MessageInterpolator interpolator = getDefaultMessageInterpolator();
    ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" );
    MessageInterpolator.Context context = new TestContext( descriptor );

    String expected = "{";
    String actual = interpolator.interpolate( "\\{", context );
    assertEquals( actual, expected, "Wrong substitution" );

    expected = "}";
    actual = interpolator.interpolate( "\\}", context );
    assertEquals( actual, expected, "Wrong substitution" );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.