use of org.springframework.core.convert.support.DefaultConversionService in project spring-framework by spring-projects.
the class BeanWrapperEnumTests method testStandardEnumSetWithMultipleValues.
@Test
public void testStandardEnumSetWithMultipleValues() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setConversionService(new DefaultConversionService());
assertNull(gb.getStandardEnumSet());
bw.setPropertyValue("standardEnumSet", new String[] { "VALUE_1", "VALUE_2" });
assertEquals(2, gb.getStandardEnumSet().size());
assertTrue(gb.getStandardEnumSet().contains(CustomEnum.VALUE_1));
assertTrue(gb.getStandardEnumSet().contains(CustomEnum.VALUE_2));
}
use of org.springframework.core.convert.support.DefaultConversionService in project spring-framework by spring-projects.
the class BeanWrapperEnumTests method testStandardEnumMapWithMultipleValues.
@Test
public void testStandardEnumMapWithMultipleValues() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setConversionService(new DefaultConversionService());
assertNull(gb.getStandardEnumMap());
Map<String, Integer> map = new LinkedHashMap<>();
map.put("VALUE_1", 1);
map.put("VALUE_2", 2);
bw.setPropertyValue("standardEnumMap", map);
assertEquals(2, gb.getStandardEnumMap().size());
assertEquals(new Integer(1), gb.getStandardEnumMap().get(CustomEnum.VALUE_1));
assertEquals(new Integer(2), gb.getStandardEnumMap().get(CustomEnum.VALUE_2));
}
use of org.springframework.core.convert.support.DefaultConversionService in project spring-boot by spring-projects.
the class RelaxedDataBinderTests method testBindNestedMapOfEnumRelaxedNames.
@Test
public void testBindNestedMapOfEnumRelaxedNames() throws Exception {
this.conversionService = new DefaultConversionService();
TargetWithNestedMapOfEnum target = new TargetWithNestedMapOfEnum();
bind(target, "nested.the-other: bar\n" + "nested.that_other: 123");
assertThat(target.getNested().get(Bingo.THE_OTHER)).isEqualTo("bar");
assertThat(target.getNested().get(Bingo.THAT_OTHER)).isEqualTo("123");
}
use of org.springframework.core.convert.support.DefaultConversionService in project spring-boot by spring-projects.
the class RelaxedDataBinderTests method testBindNestedSetCommaDelimitedOnly.
@Test
public void testBindNestedSetCommaDelimitedOnly() throws Exception {
TargetWithNestedSet target = new TargetWithNestedSet();
this.conversionService = new DefaultConversionService();
bind(target, "nested: bar,foo");
assertThat(target.getNested().toString()).isEqualTo("[bar, foo]");
}
use of org.springframework.core.convert.support.DefaultConversionService in project spring-boot by spring-projects.
the class RelaxedDataBinderTests method testBindNestedMapOfEnum.
@Test
public void testBindNestedMapOfEnum() throws Exception {
this.conversionService = new DefaultConversionService();
TargetWithNestedMapOfEnum target = new TargetWithNestedMapOfEnum();
bind(target, "nested.this: bar\n" + "nested.ThAt: 123");
assertThat(target.getNested().get(Bingo.THIS)).isEqualTo("bar");
assertThat(target.getNested().get(Bingo.THAT)).isEqualTo("123");
}
Aggregations