forked from FasterXML/jackson-databind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.10' of github.com:FasterXML/jackson-databind into 2.10
- Loading branch information
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/test/java/com/fasterxml/jackson/failing/Alias2378Test.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,63 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAlias; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
// for [databind#2378] | ||
public class Alias2378Test extends BaseMapTest | ||
{ | ||
static abstract class UserEventContext { | ||
public abstract String getId(); | ||
|
||
public abstract String getPartitionId(); | ||
|
||
@JsonCreator | ||
public static UserEventContext create(@JsonProperty("partitionId") String partitionId, | ||
@JsonProperty("id") @JsonAlias("userId") String userId) { | ||
return new AutoValue_UserEventContext(userId, partitionId); | ||
} | ||
} | ||
|
||
static class AutoValue_UserEventContext extends UserEventContext { | ||
|
||
private final String id; | ||
|
||
private final String partitionId; | ||
|
||
AutoValue_UserEventContext(String id, String partitionId) { | ||
if (id == null) { | ||
throw new NullPointerException("Null id"); | ||
} | ||
this.id = id; | ||
if (partitionId == null) { | ||
throw new NullPointerException("Null partitionId"); | ||
} | ||
this.partitionId = partitionId; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public String getPartitionId() { | ||
return partitionId; | ||
} | ||
} | ||
|
||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
public void testIssue2378() throws Exception | ||
{ | ||
UserEventContext value = MAPPER.readValue( | ||
aposToQuotes("{'userId' : 'abc', 'partitionId' : '123' }" | ||
// aposToQuotes("{'id' : 'abc', 'partitionId' : '123' }" | ||
), UserEventContext.class); | ||
assertNotNull(value); | ||
} | ||
} |