-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathReaderForUpdating5281Test.java
More file actions
47 lines (37 loc) · 1.43 KB
/
ReaderForUpdating5281Test.java
File metadata and controls
47 lines (37 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package tools.jackson.databind.tofix;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import org.junit.jupiter.api.Test;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.json.JsonMapper;
import tools.jackson.databind.testutil.DatabindTestUtil;
import tools.jackson.databind.testutil.failure.JacksonTestFailureExpected;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
// [databind#5281] Reading into existing instance uses creator property setup instead
// of accessor #5281
public class ReaderForUpdating5281Test
extends DatabindTestUtil
{
public static class ArrayListHolder {
// Works when annotated with...
// @JsonMerge
Collection<String> values;
public ArrayListHolder(String... values) {
this.values = new ArrayList<>();
this.values.addAll(Arrays.asList(values));
}
public void setValues(Collection<String> values) {
this.values = values;
}
}
@JacksonTestFailureExpected
@Test
public void readsIntoCreator() throws Exception {
ObjectMapper mapper = JsonMapper.builder().build();
ArrayListHolder holder = mapper.readerForUpdating(new ArrayListHolder("A"))
.readValue("{ \"values\" : [ \"A\", \"B\" ]}");
assertThat(holder.values).hasSize(3)
.containsAll(Arrays.asList("A", "A", "B"));
}
}