new tests for andy
This commit is contained in:
parent
6598fd736d
commit
e85a6740d8
|
|
@ -25,6 +25,7 @@ import java.util.Map;
|
|||
* @since 3.0
|
||||
* @see Binder#bind(Map)
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MissingSourceValuesException extends RuntimeException {
|
||||
|
||||
private List<String> missing;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package org.springframework.ui.binding;
|
|||
* @since 3.0
|
||||
* @see BindingFactory#getBinding(String)
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class NoSuchBindingException extends RuntimeException {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -361,11 +361,12 @@ public class GenericBinderTests {
|
|||
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");
|
||||
values.put("favoriteFoodsByGroup['DAIRY']", "Milk");
|
||||
values.put("favoriteFoodsByGroup['FRUIT']", "Peaches");
|
||||
values.put("favoriteFoodsByGroup['MEAT']", "Ham");
|
||||
BindingResults results = binder.bind(values);
|
||||
System.out.println(results);
|
||||
System.out.println(results);
|
||||
Assert.assertEquals(3, bean.favoriteFoodsByGroup.size());
|
||||
assertEquals("Milk", bean.favoriteFoodsByGroup.get(FoodGroup.DAIRY));
|
||||
assertEquals("Peaches", bean.favoriteFoodsByGroup.get(FoodGroup.FRUIT));
|
||||
|
|
@ -399,6 +400,19 @@ public class GenericBinderTests {
|
|||
assertEquals("DAIRY=Milk FRUIT=Peaches MEAT=Ham", value);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void bindToNullObjectPath() {
|
||||
binder.addBinding("primaryAddress.street");
|
||||
binder.addBinding("primaryAddress.city");
|
||||
binder.addBinding("primaryAddress.state");
|
||||
binder.addBinding("primaryAddress.zip");
|
||||
Map<String, String> values = new LinkedHashMap<String, String>();
|
||||
values.put("primaryAddress.city", "Melbourne");
|
||||
binder.bind(values);
|
||||
Assert.assertEquals("Melbourne", bean.primaryAddress.city);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatPossibleValue() {
|
||||
binder.addBinding("currency").formatWith(new CurrencyFormatter());
|
||||
|
|
@ -423,6 +437,10 @@ public class GenericBinderTests {
|
|||
private List<FooEnum> foos;
|
||||
private List<Address> addresses;
|
||||
private Map<FoodGroup, String> favoriteFoodsByGroup;
|
||||
private Address primaryAddress;
|
||||
|
||||
public TestBean() {
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return string;
|
||||
|
|
@ -489,6 +507,14 @@ public class GenericBinderTests {
|
|||
this.favoriteFoodsByGroup = favoriteFoodsByGroup;
|
||||
}
|
||||
|
||||
public Address getPrimaryAddress() {
|
||||
return primaryAddress;
|
||||
}
|
||||
|
||||
public void setPrimaryAddress(Address primaryAddress) {
|
||||
this.primaryAddress = primaryAddress;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class AddressFormatter implements Formatter<Address> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue