mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-24 15:49:26 +00:00
Add converters between Enum and Integer
This commit is contained in:
committed by
Stephane Nicoll
parent
183594207f
commit
1a302e1fac
+20
@@ -243,6 +243,26 @@ public class DefaultConversionServiceTests {
|
||||
public void testEnumToString() {
|
||||
assertEquals("BAR", conversionService.convert(Foo.BAR, String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntegerToEnum() throws Exception {
|
||||
assertEquals(Foo.BAR, conversionService.convert(0, Foo.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntegerToEnumWithSubclass() throws Exception {
|
||||
assertEquals(SubFoo.BAZ, conversionService.convert(1, SubFoo.BAR.getClass()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntegerToEnumNull() {
|
||||
assertEquals(null, conversionService.convert(null, Foo.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnumToInteger() {
|
||||
assertEquals(0, conversionService.convert(Foo.BAR, Integer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringToEnumSet() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user