Skip to content

Commit 8f0d07d

Browse files
committed
Merge branch '2.10' of github.com:FasterXML/jackson-databind into 2.10
2 parents 620850e + c3b52ec commit 8f0d07d

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import com.fasterxml.jackson.annotation.JsonAlias;
4+
import com.fasterxml.jackson.annotation.JsonCreator;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
import com.fasterxml.jackson.databind.BaseMapTest;
8+
import com.fasterxml.jackson.databind.ObjectMapper;
9+
10+
// for [databind#2378]
11+
public class Alias2378Test extends BaseMapTest
12+
{
13+
static abstract class UserEventContext {
14+
public abstract String getId();
15+
16+
public abstract String getPartitionId();
17+
18+
@JsonCreator
19+
public static UserEventContext create(@JsonProperty("partitionId") String partitionId,
20+
@JsonProperty("id") @JsonAlias("userId") String userId) {
21+
return new AutoValue_UserEventContext(userId, partitionId);
22+
}
23+
}
24+
25+
static class AutoValue_UserEventContext extends UserEventContext {
26+
27+
private final String id;
28+
29+
private final String partitionId;
30+
31+
AutoValue_UserEventContext(String id, String partitionId) {
32+
if (id == null) {
33+
throw new NullPointerException("Null id");
34+
}
35+
this.id = id;
36+
if (partitionId == null) {
37+
throw new NullPointerException("Null partitionId");
38+
}
39+
this.partitionId = partitionId;
40+
}
41+
42+
@Override
43+
public String getId() {
44+
return id;
45+
}
46+
47+
@Override
48+
public String getPartitionId() {
49+
return partitionId;
50+
}
51+
}
52+
53+
private final ObjectMapper MAPPER = newJsonMapper();
54+
55+
public void testIssue2378() throws Exception
56+
{
57+
UserEventContext value = MAPPER.readValue(
58+
aposToQuotes("{'userId' : 'abc', 'partitionId' : '123' }"
59+
// aposToQuotes("{'id' : 'abc', 'partitionId' : '123' }"
60+
), UserEventContext.class);
61+
assertNotNull(value);
62+
}
63+
}

0 commit comments

Comments
 (0)