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
        final ObjectMapper mapperWithNames = new ObjectMapper()
            .registerModule(new ParameterNamesModule());
        json = mapperWithNames.writeValueAsString(SurprisingEnum32.ENUM_NAME);
        assertEquals(EXP, json);

        // plus read back:
        SurprisingEnum32 value = mapperWithNames.readValue(json, SurprisingEnum32.class);
        assertEquals(SurprisingEnum32.ENUM_NAME, value);
    }
}

@@ -54,25 +54,54 @@
 ort 
-org.junit.Test
+com.fasterxml.jackson.annotation.JsonCreator
 ;%0A
-%0A
 impo
@@ -150,16 +150,67 @@
 operty;%0A
+import com.fasterxml.jackson.annotation.JsonValue;%0A
 import c
@@ -300,16 +300,40 @@
 quals;%0A%0A
+import org.junit.Test;%0A%0A
 public c
@@ -351,16 +351,39 @@
 mingTest
+ extends ModuleTestBase
 %0A%7B%0A    e
@@ -471,51 +471,940 @@
   %7D%0A
+%0A
     
-%0A    // for %5Bmodule-parameter-names#32%5D
+// %5Bmodules-java8#234%5D%0A    static enum MeetingStatus %7B%0A        UNKNOWN(0),%0A        INITIALIZING(1),%0A        PROGRESSING(2),%0A        TERMINATED(3),%0A        ;%0A%0A        public final int status;%0A%0A        @JsonValue%0A        public int getStatus() %7B%0A            return status;%0A        %7D%0A%0A        MeetingStatus(int status) %7B%0A            this.status = status;%0A        %7D%0A%0A        @JsonCreator(mode = JsonCreator.Mode.DELEGATING)%0A        public static MeetingStatus parse(Integer status) %7B%0A            if (status == null) %7B%0A                return UNKNOWN;%0A            %7D%0A            int s = status.intValue();%0A            for (MeetingStatus value : values()) %7B%0A                if (s == value.status) %7B%0A                    return value;%0A                %7D%0A            %7D%0A            return UNKNOWN;%0A        %7D%0A%0A    %7D%0A%0A    static class Meeting %7B%0A        public MeetingStatus status;%0A    %7D%0A%0A    private final ObjectMapper MAPPER = newMapper();%0A
 %0A   
@@ -1590,34 +1590,22 @@
  json = 
-new ObjectMapper()
+MAPPER
 %0A       
@@ -2091,16 +2091,16 @@
 class);%0A
-
         
@@ -2153,11 +2153,493 @@
 );%0A    %7D
+%0A%0A    // %5Bmodules-java8#234%5D%0A    @Test%0A    public void testEnumWithCreator() throws Exception%0A    %7B%0A        // it's ok when serializing%0A        Meeting meetingSrc = new Meeting();%0A        meetingSrc.status = MeetingStatus.PROGRESSING;%0A%0A        String json = MAPPER.writeValueAsString(meetingSrc);%0A%0A        // but throws exception when deserializing%0A        Meeting result = MAPPER.readValue(json, Meeting.class);%0A        assertEquals(MeetingStatus.PROGRESSING, result.status);%0A    %7D
 %0A%7D%0A

Add a test case for #234