Skip to content

Commit 9c2e89b

Browse files
committed
Add failing test for #1291
1 parent 07569c7 commit 9c2e89b

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import com.fasterxml.jackson.databind.BaseMapTest;
4+
import com.fasterxml.jackson.databind.ObjectMapper;
5+
6+
public class EnumCreator1291Test extends BaseMapTest
7+
{
8+
static enum Enum1291 {
9+
10+
V1("val1"),
11+
V2("val2"),
12+
V3("val3"),
13+
V4("val4"),
14+
V5("val5"),
15+
V6("val6");
16+
17+
private final String name;
18+
19+
Enum1291(String name) {
20+
this.name = name;
21+
}
22+
23+
public static Enum1291 fromString(String name) {
24+
for (Enum1291 type : Enum1291.values()) {
25+
if (type.name.equals(name)) {
26+
return type;
27+
}
28+
}
29+
return Enum1291.valueOf(name.toUpperCase());
30+
}
31+
32+
@Override
33+
public String toString() {
34+
return name;
35+
}
36+
}
37+
38+
public void testEnumCreators1291() throws Exception
39+
{
40+
ObjectMapper mapper = new ObjectMapper();
41+
String json = mapper.writeValueAsString(Enum1291.V2);
42+
Enum1291 result = mapper.readValue(json, Enum1291.class);
43+
assertSame(Enum1291.V2, result);
44+
}
45+
}

0 commit comments

Comments
 (0)