DATAMONGO-2410 - Polishing.
Simplify cast. Extend test with DBObject interface. Original pull request: #813.
This commit is contained in:
@@ -253,7 +253,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
||||
return (S) new BasicDBObject((Document) bson);
|
||||
}
|
||||
|
||||
return (S) DBObject.class.cast(bson);
|
||||
return (S) bson;
|
||||
}
|
||||
|
||||
if (typeToUse.isCollectionLike() && bson instanceof List) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.springframework.data.mongodb.core.DocumentTestUtils.*;
|
||||
|
||||
import com.mongodb.DBObject;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@@ -2070,9 +2071,11 @@ public class MappingMongoConverterUnitTests {
|
||||
|
||||
@Test // DATAMONGO-2410
|
||||
public void shouldAllowReadingBackDbObject() {
|
||||
|
||||
|
||||
assertThat(converter.read(BasicDBObject.class, new org.bson.Document("property", "value")))
|
||||
.isEqualTo(new BasicDBObject("property", "value"));
|
||||
assertThat(converter.read(DBObject.class, new org.bson.Document("property", "value")))
|
||||
.isEqualTo(new BasicDBObject("property", "value"));
|
||||
}
|
||||
|
||||
static class GenericType<T> {
|
||||
|
||||
Reference in New Issue
Block a user