提交 2bd30a49 编写于 作者: K Keith Donald

more tests

上级 7a6dafd5
...@@ -38,7 +38,7 @@ class MapEntryConverter { ...@@ -38,7 +38,7 @@ class MapEntryConverter {
if (this.valueConverter == null) { if (this.valueConverter == null) {
throw new ConverterNotFoundException(sourceValueType, targetValueType); throw new ConverterNotFoundException(sourceValueType, targetValueType);
} }
this.targetKeyType = targetKeyType; this.sourceValueType = sourceValueType;
this.targetValueType = targetValueType; this.targetValueType = targetValueType;
} }
} }
......
...@@ -417,6 +417,21 @@ public class GenericConversionServiceTests { ...@@ -417,6 +417,21 @@ public class GenericConversionServiceTests {
assertEquals(new Integer(3), result[0]); assertEquals(new Integer(3), result[0]);
} }
@Test
public void convertObjectToMap() {
Map result = conversionService.convert("foo=bar bar=baz", Map.class);
assertEquals("bar", result.get("foo"));
assertEquals("baz", result.get("bar"));
}
@Test
public void convertObjectToMapWithConversion() throws Exception {
conversionService.addConverterFactory(new NumberToNumberConverterFactory());
Map result = (Map) conversionService.convert(1L, TypeDescriptor.valueOf(Integer.class), new TypeDescriptor(
getClass().getField("genericMap2")));
assertEquals(new Long(1), result.get(1L));
}
@Test @Test
public void convertStringArrayToMap() { public void convertStringArrayToMap() {
Map result = conversionService.convert(new String[] { "foo=bar", "bar=baz", "baz=boop" }, Map.class); Map result = conversionService.convert(new String[] { "foo=bar", "bar=baz", "baz=boop" }, Map.class);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册