polish
This commit is contained in:
parent
80760ed7a4
commit
2db239031f
|
|
@ -756,7 +756,6 @@ public class GenericBinder implements Binder {
|
||||||
if (cause instanceof SpelEvaluationException
|
if (cause instanceof SpelEvaluationException
|
||||||
&& ((SpelEvaluationException) cause).getMessageCode() == SpelMessage.TYPE_CONVERSION_ERROR) {
|
&& ((SpelEvaluationException) cause).getMessageCode() == SpelMessage.TYPE_CONVERSION_ERROR) {
|
||||||
// TODO this could be a ConverterExecutorNotFoundException if no suitable converter was found
|
// TODO this could be a ConverterExecutorNotFoundException if no suitable converter was found
|
||||||
cause.getCause().printStackTrace();
|
|
||||||
ConversionFailedException failure = (ConversionFailedException) cause.getCause();
|
ConversionFailedException failure = (ConversionFailedException) cause.getCause();
|
||||||
MessageBuilder builder = new MessageBuilder(messageSource);
|
MessageBuilder builder = new MessageBuilder(messageSource);
|
||||||
builder.code("conversionFailed");
|
builder.code("conversionFailed");
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ public class GenericBinderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getListAsSingleValue() {
|
public void getListAsSingleString() {
|
||||||
binder.addBinding("addresses");
|
binder.addBinding("addresses");
|
||||||
binder.registerFormatter(new GenericCollectionPropertyType(List.class, Address.class), new AddressListFormatter());
|
binder.registerFormatter(new GenericCollectionPropertyType(List.class, Address.class), new AddressListFormatter());
|
||||||
Address address1 = new Address();
|
Address address1 = new Address();
|
||||||
|
|
@ -341,6 +341,63 @@ public class GenericBinderTests {
|
||||||
assertEquals(12, results.size());
|
assertEquals(12, results.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void bindToMap() {
|
||||||
|
binder.addBinding("favoriteFoodsByGroup");
|
||||||
|
Map<String, String[]> values = new LinkedHashMap<String, String[]>();
|
||||||
|
values.put("favoriteFoodsByGroup", new String[] { "DAIRY=Milk", "FRUIT=Peaches", "MEAT=Ham" });
|
||||||
|
BindingResults results = binder.bind(values);
|
||||||
|
System.out.println(results);
|
||||||
|
Assert.assertEquals(3, bean.favoriteFoodsByGroup.size());
|
||||||
|
assertEquals("Milk", bean.favoriteFoodsByGroup.get(FoodGroup.DAIRY));
|
||||||
|
assertEquals("Peaches", bean.favoriteFoodsByGroup.get(FoodGroup.FRUIT));
|
||||||
|
assertEquals("Ham", bean.favoriteFoodsByGroup.get(FoodGroup.MEAT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void bindToMapElements() {
|
||||||
|
binder.addBinding("favoriteFoodsByGroup");
|
||||||
|
Map<String, String> values = new LinkedHashMap<String, String>();
|
||||||
|
values.put("favoriteFoodsByGroup[DAIRY]", "Milk");
|
||||||
|
values.put("favoriteFoodsByGroup[FRUIT]", "Peaches");
|
||||||
|
values.put("favoriteFoodsByGroup[MEAT]", "Ham");
|
||||||
|
BindingResults results = binder.bind(values);
|
||||||
|
System.out.println(results);
|
||||||
|
Assert.assertEquals(3, bean.favoriteFoodsByGroup.size());
|
||||||
|
assertEquals("Milk", bean.favoriteFoodsByGroup.get(FoodGroup.DAIRY));
|
||||||
|
assertEquals("Peaches", bean.favoriteFoodsByGroup.get(FoodGroup.FRUIT));
|
||||||
|
assertEquals("Ham", bean.favoriteFoodsByGroup.get(FoodGroup.MEAT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void bindToMapSingleString() {
|
||||||
|
binder.addBinding("favoriteFoodsByGroup");
|
||||||
|
Map<String, String> values = new LinkedHashMap<String, String>();
|
||||||
|
values.put("favoriteFoodsByGroup", "DAIRY=Milk FRUIT=Peaches MEAT=Ham");
|
||||||
|
BindingResults results = binder.bind(values);
|
||||||
|
System.out.println(results);
|
||||||
|
Assert.assertEquals(3, bean.favoriteFoodsByGroup.size());
|
||||||
|
assertEquals("Milk", bean.favoriteFoodsByGroup.get(FoodGroup.DAIRY));
|
||||||
|
assertEquals("Peaches", bean.favoriteFoodsByGroup.get(FoodGroup.FRUIT));
|
||||||
|
assertEquals("Ham", bean.favoriteFoodsByGroup.get(FoodGroup.MEAT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void getMapAsSingleString() {
|
||||||
|
binder.addBinding("favoriteFoodsByGroup");
|
||||||
|
Map<FoodGroup, String> foods = new LinkedHashMap<FoodGroup, String>();
|
||||||
|
foods.put(FoodGroup.DAIRY, "Milk");
|
||||||
|
foods.put(FoodGroup.FRUIT, "Peaches");
|
||||||
|
foods.put(FoodGroup.MEAT, "Ham");
|
||||||
|
bean.favoriteFoodsByGroup = foods;
|
||||||
|
String value = binder.getBinding("favoriteFoodsByGroup").getValue();
|
||||||
|
assertEquals("DAIRY=Milk FRUIT=Peaches MEAT=Ham", value);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void formatPossibleValue() {
|
public void formatPossibleValue() {
|
||||||
binder.addBinding("currency").formatWith(new CurrencyFormatter());
|
binder.addBinding("currency").formatWith(new CurrencyFormatter());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue