use of cn.taketoday.beans.PropertyValue in project today-infrastructure by TAKETODAY.
the class RequestContextDataBinderTests method doTestTony.
/**
* Must contain: forname=Tony surname=Blair age=50
*/
protected void doTestTony(PropertyValues pvs) throws Exception {
assertThat(pvs.toArray().length == 3).as("Contains 3").isTrue();
assertThat(pvs.contains("forname")).as("Contains forname").isTrue();
assertThat(pvs.contains("surname")).as("Contains surname").isTrue();
assertThat(pvs.contains("age")).as("Contains age").isTrue();
boolean condition1 = !pvs.contains("tory");
assertThat(condition1).as("Doesn't contain tory").isTrue();
PropertyValue[] pvArray = pvs.toArray();
Map<String, String> m = new HashMap<>();
m.put("forname", "Tony");
m.put("surname", "Blair");
m.put("age", "50");
for (PropertyValue pv : pvArray) {
Object val = m.get(pv.getName());
assertThat(val != null).as("Can't have unexpected value").isTrue();
boolean condition = val instanceof String;
assertThat(condition).as("Val i string").isTrue();
assertThat(val.equals(pv.getValue())).as("val matches expected").isTrue();
m.remove(pv.getName());
}
assertThat(m.size() == 0).as("Map size is 0").isTrue();
}
Aggregations