public void test_Trim_Render_Contribution()
{
IFormComponent field = newField("Number Field", "myfield", 2);
NumberTranslator translator = new NumberTranslator();
JSONObject json = new JSONObject();
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycle();
FormComponentContributorContext context = newMock(FormComponentContributorContext.class);
expect(context.getProfile()).andReturn(json);
trainGetLocale(context, Locale.ENGLISH);
trainBuildMessage(context, null, ValidationStrings.INVALID_NUMBER, new Object[]
{ "Number Field", "#" }, "invalid number message");
expect(context.getProfile()).andReturn(json);
replay();
translator.setTrim(true);
translator.renderContribution(writer, cycle, context, field);
verify();
assertEquals(json.toString(),
"{\"trim\":[\"myfield\"],\"constraints\":{\"myfield\":" +
"[[dojo.validate.isRealNumber,{places:0,decimal:\".\",separator:\",\"}]]}," +
"\"myfield\":{\"constraints\":[\"invalid number message\"]}}");
}