use of cn.taketoday.beans.testfixture.beans.GenericBean in project today-infrastructure by TAKETODAY.
the class BeanWrapperGenericsTests method testGenericListElement.
@Test
void testGenericListElement() throws Exception {
GenericBean<?> gb = new GenericBean<>();
gb.setResourceList(new ArrayList<>());
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("resourceList[0]", "http://localhost:8080");
assertThat(gb.getResourceList().get(0)).isEqualTo(new UrlBasedResource("http://localhost:8080"));
}
use of cn.taketoday.beans.testfixture.beans.GenericBean in project today-infrastructure by TAKETODAY.
the class BeanWrapperGenericsTests method testGenericMapFromProperties.
@Test
void testGenericMapFromProperties() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
Properties input = new Properties();
input.setProperty("4", "5");
input.setProperty("6", "7");
bw.setPropertyValue("shortMap", input);
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
assertThat(gb.getShortMap().get(Short.valueOf("6"))).isEqualTo(7);
}
use of cn.taketoday.beans.testfixture.beans.GenericBean in project today-infrastructure by TAKETODAY.
the class BeanWrapperGenericsTests method testGenericList.
@Test
void testGenericList() throws Exception {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
List<String> input = new ArrayList<>();
input.add("http://localhost:8080");
input.add("http://localhost:9090");
bw.setPropertyValue("resourceList", input);
assertThat(gb.getResourceList().get(0)).isEqualTo(new UrlBasedResource("http://localhost:8080"));
assertThat(gb.getResourceList().get(1)).isEqualTo(new UrlBasedResource("http://localhost:9090"));
}
use of cn.taketoday.beans.testfixture.beans.GenericBean in project today-infrastructure by TAKETODAY.
the class BeanWrapperGenericsTests method testGenericLowerBoundedSet.
@Test
void testGenericLowerBoundedSet() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, true));
Set<String> input = new HashSet<>();
input.add("4");
input.add("5");
bw.setPropertyValue("numberSet", input);
assertThat(gb.getNumberSet().contains(4)).isTrue();
assertThat(gb.getNumberSet().contains(5)).isTrue();
}
use of cn.taketoday.beans.testfixture.beans.GenericBean in project today-framework by TAKETODAY.
the class BeanWrapperEnumTests method testStandardEnumSetWithMultipleValues.
@Test
public void testStandardEnumSetWithMultipleValues() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setConversionService(new DefaultConversionService());
assertThat(gb.getStandardEnumSet()).isNull();
bw.setPropertyValue("standardEnumSet", new String[] { "VALUE_1", "VALUE_2" });
assertThat(gb.getStandardEnumSet().size()).isEqualTo(2);
assertThat(gb.getStandardEnumSet().contains(CustomEnum.VALUE_1)).isTrue();
assertThat(gb.getStandardEnumSet().contains(CustomEnum.VALUE_2)).isTrue();
}
Aggregations