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

Commit

Permalink
Add a (failing) test for #32
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Mar 13, 2016
1 parent 580210e commit 1dc3548
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.fasterxml.jackson.module.paramnames;

import org.junit.Test;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;

import static org.junit.Assert.assertEquals;

public class EnumNamingTest
{
enum SurprisingEnum32 {
@JsonProperty("customValue")
ENUM_NAME;
}

// for [module-parameter-names#32]
@Test
public void testCustomEnumName() throws Exception
{
final String EXP = "\"customValue\"";

// First, verify default handling

String json = new ObjectMapper()
.writeValueAsString(SurprisingEnum32.ENUM_NAME);
assertEquals(EXP, json);

// and then with parameter names module
json = new ObjectMapper()
.registerModule(new ParameterNamesModule())
.writeValueAsString(SurprisingEnum32.ENUM_NAME);
assertEquals(EXP, json);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;

public class PersonTest {

public class PersonTest
{
@Test
public void shouldBeAbleToDeserializePerson() throws IOException {

public void shouldBeAbleToDeserializePerson() throws IOException
{
// given
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new ParameterNamesModule());
ObjectMapper objectMapper = new ObjectMapper()
.registerModule(new ParameterNamesModule());

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

0 comments on commit 1dc3548

Please sign in to comment.