VRaptorConvertersAdapter implements TypeConverter { Object convert(Object value, Class type) { Converter<?> converter = converters.to(type); if (converter == null) { throw new IllegalArgumentException("Cannot instantiate a converter for type " + type.getName()); } return converter.convert((String) value, type, bundle); } VRaptorConvertersAdapter(Converters converters, ResourceBundle bundle); Object convertValue(Map context, Object target, Member member, String propertyName, Object value,
		Class toType);  }
@Test @SuppressWarnings("unchecked") public void shouldInvokePrimitiveConverter() throws OgnlException { when(converters.to(int.class)).thenReturn(converter); when(converter.convert("2", int.class, bundle)).thenReturn(2); Map<?,?> context = Ognl.createDefaultContext(myCat); Ognl.setTypeConverter(context, adapter); Ognl.setValue("length", context, myCat, "2"); assertThat(myCat.length, is(equalTo(2))); }
@SuppressWarnings("unchecked") @Test public void shouldInvokeCustomTypeConverter() throws OgnlException { when(converters.to(Tail.class)).thenReturn(converter); when(converter.convert("15", Tail.class, bundle)).thenReturn(new Tail(15)); Map<?,?> context = Ognl.createDefaultContext(myCat); Ognl.setTypeConverter(context, adapter); Ognl.setValue("tail", context, myCat, "15"); assertThat(myCat.tail.length, is(equalTo(15))); }