|
32 | 32 | import java.math.BigInteger;
|
33 | 33 | import java.net.URL;
|
34 | 34 | import java.time.LocalDateTime;
|
35 |
| -import java.util.ArrayList; |
36 |
| -import java.util.Arrays; |
37 |
| -import java.util.Collection; |
38 |
| -import java.util.Collections; |
39 |
| -import java.util.Date; |
40 |
| -import java.util.EnumMap; |
41 |
| -import java.util.EnumSet; |
42 |
| -import java.util.HashMap; |
43 |
| -import java.util.LinkedHashMap; |
44 |
| -import java.util.List; |
45 |
| -import java.util.Locale; |
46 |
| -import java.util.Map; |
47 |
| -import java.util.Optional; |
48 |
| -import java.util.Set; |
49 |
| -import java.util.SortedMap; |
50 |
| -import java.util.TreeMap; |
| 35 | +import java.util.*; |
51 | 36 |
|
52 | 37 | import org.bson.types.ObjectId;
|
53 | 38 | import org.hamcrest.Matcher;
|
@@ -1886,6 +1871,17 @@ public void readsNestedArraysCorrectly() {
|
1886 | 1871 | assertThat(result.nestedFloats).isEqualTo(new float[][][] { { { 1.0f, 2.0f } } });
|
1887 | 1872 | }
|
1888 | 1873 |
|
| 1874 | + @Test // DATAMONGO-1992 |
| 1875 | + public void readsImmutableObjectCorrectly() { |
| 1876 | + |
| 1877 | + org.bson.Document document = new org.bson.Document("_id", "foo"); |
| 1878 | + |
| 1879 | + ImmutableObject result = converter.read(ImmutableObject.class, document); |
| 1880 | + |
| 1881 | + assertThat(result.id).isEqualTo("foo"); |
| 1882 | + assertThat(result.witherUsed).isTrue(); |
| 1883 | + } |
| 1884 | + |
1889 | 1885 | static class GenericType<T> {
|
1890 | 1886 | T content;
|
1891 | 1887 | }
|
@@ -2266,4 +2262,44 @@ static class DocWithInterfacedEnum {
|
2266 | 2262 | static class WithNestedLists {
|
2267 | 2263 | float[][][] nestedFloats;
|
2268 | 2264 | }
|
| 2265 | + |
| 2266 | + static class ImmutableObject { |
| 2267 | + final String id; |
| 2268 | + final String name; |
| 2269 | + final boolean witherUsed; |
| 2270 | + |
| 2271 | + private ImmutableObject(String id) { |
| 2272 | + this.id = id; |
| 2273 | + this.name = null; |
| 2274 | + this.witherUsed = false; |
| 2275 | + } |
| 2276 | + |
| 2277 | + private ImmutableObject(String id, String name, boolean witherUsed) { |
| 2278 | + this.id = id; |
| 2279 | + this.name = name; |
| 2280 | + this.witherUsed = witherUsed; |
| 2281 | + } |
| 2282 | + |
| 2283 | + public ImmutableObject() { |
| 2284 | + this.id = null; |
| 2285 | + this.name = null; |
| 2286 | + witherUsed = false; |
| 2287 | + } |
| 2288 | + |
| 2289 | + public ImmutableObject withId(String id) { |
| 2290 | + return new ImmutableObject(id, name, true); |
| 2291 | + } |
| 2292 | + |
| 2293 | + public String getId() { |
| 2294 | + return id; |
| 2295 | + } |
| 2296 | + |
| 2297 | + public String getName() { |
| 2298 | + return name; |
| 2299 | + } |
| 2300 | + |
| 2301 | + public boolean isWitherUsed() { |
| 2302 | + return witherUsed; |
| 2303 | + } |
| 2304 | + } |
2269 | 2305 | }
|
0 commit comments