@Test public void testBindDateTimeAnnotatedDefault() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("dateTimeAnnotatedDefault", new DateTime(2009, 10, 31, 12, 0, ISOChronology.getInstanceUTC())); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); String value = binder.getBindingResult().getFieldValue("dateTimeAnnotatedDefault").toString(); assertTrue(value.startsWith("10/31/09")); }
@Test public void testBindLocalDateTime() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("localDateTime", new LocalDateTime(2009, 10, 31, 12, 0)); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); String value = binder.getBindingResult().getFieldValue("localDateTime").toString(); assertTrue(value.startsWith("10/31/09")); assertTrue(value.endsWith("12:00 PM")); }
@Test public void testBindLocalDateTimeAnnotated() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("localDateTimeAnnotated", new LocalDateTime(2009, 10, 31, 12, 0)); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); String value = binder.getBindingResult().getFieldValue("localDateTimeAnnotated").toString(); assertTrue(value.startsWith("Oct 31, 2009")); assertTrue(value.endsWith("12:00 PM")); }
@Test public void testBindInstant() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("instant", "2009-10-31T12:00:00.000Z"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertTrue(binder.getBindingResult().getFieldValue("instant").toString().startsWith("2009-10-31T12:00")); }
@Test public void testPatternList2FormattingListElement() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("patternList2[0]", "1,25.00"); propertyValues.add("patternList2[1]", "2,35.00"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("1,25.00", binder.getBindingResult().getFieldValue("patternList2[0]")); assertEquals("2,35.00", binder.getBindingResult().getFieldValue("patternList2[1]")); }
@Test public void testBindCalendarAnnotated() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("calendarAnnotated", "10/31/09"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("10/31/09", binder.getBindingResult().getFieldValue("calendarAnnotated")); }
@Test public void testBindISODateTime() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("isoDateTime", "2009-10-31T12:00:00.000Z"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("2009-10-31T07:00:00.000-05:00", binder.getBindingResult().getFieldValue("isoDateTime")); }
@Test public void testPercentFormatting() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("percent", "53%"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("53%", binder.getBindingResult().getFieldValue("percent")); }
@Test public void testPatternFormatting() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("pattern", "1,25.00"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("1,25.00", binder.getBindingResult().getFieldValue("pattern")); }
@Test public void testBindDateAnnotated() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("dateAnnotated", "10/31/09"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("10/31/09", binder.getBindingResult().getFieldValue("dateAnnotated")); }
@Test public void testBindLocalDate() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("localDate", "10/31/09"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("10/31/09", binder.getBindingResult().getFieldValue("localDate")); }
@Test public void testBindLocalDateAnnotatedWithError() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("localDateAnnotated", "Oct -31, 2009"); binder.bind(propertyValues); assertEquals(1, binder.getBindingResult().getFieldErrorCount("localDateAnnotated")); assertEquals("Oct -31, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated")); }
@Test public void testBindLocalDate() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("localDate", "10/31/09"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("10/31/09", binder.getBindingResult().getFieldValue("localDate")); }
@Test public void testBindDateTimeAnnotatedPattern() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("dateTimeAnnotatedPattern", "10/31/09 12:00 PM"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("10/31/09 12:00 PM", binder.getBindingResult().getFieldValue("dateTimeAnnotatedPattern")); }
@Test public void testBindISODate() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("isoDate", "2009-10-31"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("2009-10-31", binder.getBindingResult().getFieldValue("isoDate")); }
@Test public void testBindISOTime() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("isoTime", "12:00:00.000-05:00"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("12:00:00.000", binder.getBindingResult().getFieldValue("isoTime")); }
@Test public void testBindLong() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("millis", "1256961600"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("1256961600", binder.getBindingResult().getFieldValue("millis")); }
@Test public void testBindNestedDateAnnotated() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("children[0].dateAnnotated", "10/31/09"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("10/31/09", binder.getBindingResult().getFieldValue("children[0].dateAnnotated")); }
@Test public void testBindLocalDateAnnotatedWithDirectFieldAccessAndError() { binder.initDirectFieldAccess(); MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("localDateAnnotated", "Oct -31, 2009"); binder.bind(propertyValues); assertEquals(1, binder.getBindingResult().getFieldErrorCount("localDateAnnotated")); assertEquals("Oct -31, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated")); }
@Test public void testBindLocalDateAnnotatedWithDirectFieldAccess() { binder.initDirectFieldAccess(); MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("localDateAnnotated", "Oct 31, 2009"); binder.bind(propertyValues); assertEquals(0, binder.getBindingResult().getErrorCount()); assertEquals("Oct 31, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated")); }