Package javax.validation

Examples of javax.validation.MessageInterpolator.interpolate()


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

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

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


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

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

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

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

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

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

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

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

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

    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 = "4.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 = "4.3.1.1", id = "h")
View Full Code Here

    String expected = "kann nicht null sein";
    // TODO(nchalko) i18n
    //GwtLocaleFactory localeFactory = GWT.create(GwtLocaleFactory.class);
    GwtLocale german = null//localeFactory.fromComponents("de","","","");
    String actual = interpolator.interpolate(
        ( String ) descriptor.getAttributes().get( "message" ), context, german
    );
    assertEquals( actual, expected, "Wrong substitution" );
  }
View Full Code Here

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

    String messageInterpolatedWithNoLocale = interpolator.interpolate( messageTemplate, context );
    // TODO(nchalko) i18n
    //GwtLocaleFactory localeFactory = GWT.create(GwtLocaleFactory.class);
    GwtLocale defaultLocale = null; // localeFactory.getDefault();
    String messageInterpolatedWithDefaultLocale = interpolator.interpolate(
        messageTemplate, context,defaultLocale
View Full Code Here

    String messageInterpolatedWithNoLocale = interpolator.interpolate( messageTemplate, context );
    // TODO(nchalko) i18n
    //GwtLocaleFactory localeFactory = GWT.create(GwtLocaleFactory.class);
    GwtLocale defaultLocale = null; // localeFactory.getDefault();
    String messageInterpolatedWithDefaultLocale = interpolator.interpolate(
        messageTemplate, context,defaultLocale
    );

    assertEquals( messageInterpolatedWithNoLocale, messageInterpolatedWithDefaultLocale, "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.