-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2dfc5bf
commit 800eaf2
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/test/java/com/fasterxml/jackson/failing/JsonTypeInfoCaseInsensitive1983Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.MapperFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import java.io.IOException; | ||
|
||
public class JsonTypeInfoCaseInsensitive1983Test extends BaseMapTest { | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "operation") | ||
@JsonSubTypes({ | ||
@JsonSubTypes.Type(value = Equal.class, name = "eq"), | ||
@JsonSubTypes.Type(value = NotEqual.class, name = "noteq"), | ||
}) | ||
static abstract class Filter { | ||
} | ||
|
||
static class Equal extends Filter { | ||
} | ||
|
||
static class NotEqual extends Filter { | ||
} | ||
|
||
public void testReadMixedCaseSubclass() throws IOException { | ||
// There is also "ACCEPT_CASE_INSENSITIVE_VALUES" feature. Is it more suitable here, or I should leave it as is? | ||
ObjectMapper mapper = objectMapper().enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES); | ||
String serialised = "{\"operation\":\"NoTeQ\"}"; | ||
|
||
Filter result = mapper.readValue(serialised, Filter.class); | ||
|
||
assertEquals(NotEqual.class, result.getClass()); | ||
} | ||
|
||
public void testReadMixedCasePropertyName() throws IOException { | ||
ObjectMapper mapper = objectMapper().enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES); | ||
String serialised = "{\"oPeRaTioN\":\"noteq\"}"; | ||
|
||
Filter result = mapper.readValue(serialised, Filter.class); | ||
|
||
assertEquals(NotEqual.class, result.getClass()); | ||
} | ||
} |