DATAMONGO-1992 - Adapt existing tests to immutable object.
Turn immutable id properties to a mutable one to adapt with removed mutation support for final fields.
This commit is contained in:
committed by
Oliver Gierke
parent
1e49c95e41
commit
8cc4ef3c3f
@@ -34,6 +34,7 @@ import lombok.NoArgsConstructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
@@ -85,7 +86,6 @@ import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.data.mongodb.core.query.Update;
|
||||
import org.springframework.data.mongodb.test.util.MongoVersion;
|
||||
import org.springframework.data.mongodb.test.util.MongoVersionRule;
|
||||
import org.springframework.data.mongodb.util.MongoClientVersion;
|
||||
import org.springframework.data.util.CloseableIterator;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -3658,26 +3658,19 @@ public class MongoTemplateTests {
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
static class DocumentWithLazyDBRefsAndConstructorCreation {
|
||||
|
||||
@Id public final String id;
|
||||
|
||||
public DocumentWithLazyDBRefsAndConstructorCreation(String id, Sample lazyDbRefProperty,
|
||||
List<Sample> lazyDbRefAnnotatedList, Map<String, Sample> lazyDbRefAnnotatedMap) {
|
||||
this.id = id;
|
||||
this.lazyDbRefProperty = lazyDbRefProperty;
|
||||
this.lazyDbRefAnnotatedList = lazyDbRefAnnotatedList;
|
||||
this.lazyDbRefAnnotatedMap = lazyDbRefAnnotatedMap;
|
||||
}
|
||||
@Id public String id;
|
||||
|
||||
@org.springframework.data.mongodb.core.mapping.DBRef(lazy = true) //
|
||||
public final Sample lazyDbRefProperty;
|
||||
public Sample lazyDbRefProperty;
|
||||
|
||||
@Field("lazy_db_ref_list") @org.springframework.data.mongodb.core.mapping.DBRef(lazy = true) //
|
||||
public final List<Sample> lazyDbRefAnnotatedList;
|
||||
public List<Sample> lazyDbRefAnnotatedList;
|
||||
|
||||
@Field("lazy_db_ref_map") @org.springframework.data.mongodb.core.mapping.DBRef(
|
||||
lazy = true) public final Map<String, Sample> lazyDbRefAnnotatedMap;
|
||||
lazy = true) public Map<String, Sample> lazyDbRefAnnotatedMap;
|
||||
}
|
||||
|
||||
@EqualsAndHashCode
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.bson.types.ObjectId;
|
||||
|
||||
public class Person {
|
||||
|
||||
private final ObjectId id;
|
||||
private ObjectId id;
|
||||
|
||||
private String firstName;
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ package org.springframework.data.mongodb.core.aggregation;
|
||||
*/
|
||||
public class LineItem {
|
||||
|
||||
final String id;
|
||||
String id;
|
||||
|
||||
final String caption;
|
||||
String caption;
|
||||
|
||||
final double price;
|
||||
double price;
|
||||
|
||||
int quantity = 1;
|
||||
|
||||
|
||||
@@ -2079,7 +2079,7 @@ public class MappingMongoConverterUnitTests {
|
||||
@Document
|
||||
static class PrimitiveContainer {
|
||||
|
||||
@Field("property") private final int m_property;
|
||||
@Field("property") private int m_property;
|
||||
|
||||
@PersistenceConstructor
|
||||
public PrimitiveContainer(@Value("#root.property") int a_property) {
|
||||
@@ -2094,7 +2094,7 @@ public class MappingMongoConverterUnitTests {
|
||||
@Document
|
||||
static class ObjectContainer {
|
||||
|
||||
@Field("property") private final PrimitiveContainer m_property;
|
||||
@Field("property") private PrimitiveContainer m_property;
|
||||
|
||||
@PersistenceConstructor
|
||||
public ObjectContainer(@Value("#root.property") PrimitiveContainer a_property) {
|
||||
|
||||
@@ -519,7 +519,7 @@ public class MappingTests extends AbstractIntegrationTests {
|
||||
|
||||
static class Container {
|
||||
|
||||
@Id final String id;
|
||||
@Id String id;
|
||||
|
||||
public Container() {
|
||||
id = new ObjectId().toString();
|
||||
@@ -535,7 +535,7 @@ public class MappingTests extends AbstractIntegrationTests {
|
||||
|
||||
static class Item {
|
||||
|
||||
@Id final String id;
|
||||
@Id String id;
|
||||
String value;
|
||||
|
||||
public Item() {
|
||||
|
||||
@@ -20,6 +20,7 @@ import static org.springframework.data.mongodb.core.DocumentTestUtils.*;
|
||||
import static org.springframework.data.mongodb.core.query.Criteria.*;
|
||||
import static org.springframework.data.mongodb.core.query.Query.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -441,10 +442,11 @@ public class ApplicationContextEventTests {
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@org.springframework.data.mongodb.core.mapping.Document
|
||||
public static class Related {
|
||||
|
||||
final @Id Long id;
|
||||
final String description;
|
||||
@Id Long id;
|
||||
String description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
|
||||
public abstract class Contact {
|
||||
|
||||
@Id
|
||||
protected final String id;
|
||||
protected String id;
|
||||
|
||||
public Contact() {
|
||||
this.id = new ObjectId().toString();
|
||||
|
||||
Reference in New Issue
Block a user