Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Commit 1dc3548

Browse files
committed
Add a (failing) test for #32
1 parent 580210e commit 1dc3548

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.fasterxml.jackson.module.paramnames;
2+
3+
import org.junit.Test;
4+
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import com.fasterxml.jackson.databind.ObjectMapper;
7+
8+
import static org.junit.Assert.assertEquals;
9+
10+
public class EnumNamingTest
11+
{
12+
enum SurprisingEnum32 {
13+
@JsonProperty("customValue")
14+
ENUM_NAME;
15+
}
16+
17+
// for [module-parameter-names#32]
18+
@Test
19+
public void testCustomEnumName() throws Exception
20+
{
21+
final String EXP = "\"customValue\"";
22+
23+
// First, verify default handling
24+
25+
String json = new ObjectMapper()
26+
.writeValueAsString(SurprisingEnum32.ENUM_NAME);
27+
assertEquals(EXP, json);
28+
29+
// and then with parameter names module
30+
json = new ObjectMapper()
31+
.registerModule(new ParameterNamesModule())
32+
.writeValueAsString(SurprisingEnum32.ENUM_NAME);
33+
assertEquals(EXP, json);
34+
}
35+
}

src/test/java/com/fasterxml/jackson/module/paramnames/PersonTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
import com.fasterxml.jackson.databind.ObjectMapper;
88
import org.junit.Test;
99

10-
public class PersonTest {
11-
10+
public class PersonTest
11+
{
1212
@Test
13-
public void shouldBeAbleToDeserializePerson() throws IOException {
14-
13+
public void shouldBeAbleToDeserializePerson() throws IOException
14+
{
1515
// given
16-
ObjectMapper objectMapper = new ObjectMapper();
17-
objectMapper.registerModule(new ParameterNamesModule());
16+
ObjectMapper objectMapper = new ObjectMapper()
17+
.registerModule(new ParameterNamesModule());
1818

1919
// when
2020
Person actual = objectMapper.readValue("{\"name\":\"joe\",\"surname\":\"smith\",\"nickname\":\"joey\"}", Person.class);

0 commit comments

Comments
 (0)