File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 49
49
import org .springframework .core .convert .converter .Converter ;
50
50
import org .springframework .data .annotation .Id ;
51
51
import org .springframework .data .annotation .PersistenceConstructor ;
52
+ import org .springframework .data .annotation .TypeAlias ;
52
53
import org .springframework .data .mapping .PropertyPath ;
53
54
import org .springframework .data .mapping .model .MappingException ;
54
55
import org .springframework .data .mapping .model .MappingInstantiationException ;
@@ -1292,6 +1293,23 @@ public void eagerlyReturnsDBRefObjectIfTargetAlreadyIsOne() {
1292
1293
assertThat (converter .createDBRef (dbRef , annotation ), is (dbRef ));
1293
1294
}
1294
1295
1296
+ /**
1297
+ * @see DATAMONGO-523
1298
+ */
1299
+ @ Test
1300
+ public void considersTypeAliasAnnotation () {
1301
+
1302
+ Aliased aliased = new Aliased ();
1303
+ aliased .name = "foo" ;
1304
+
1305
+ DBObject result = new BasicDBObject ();
1306
+ converter .write (aliased , result );
1307
+
1308
+ Object type = result .get ("_class" );
1309
+ assertThat (type , is (notNullValue ()));
1310
+ assertThat (type .toString (), is ("_" ));
1311
+ }
1312
+
1295
1313
static class GenericType <T > {
1296
1314
T content ;
1297
1315
}
@@ -1475,6 +1493,11 @@ public TypWithCollectionConstructor(List<Attribute> attributes) {
1475
1493
}
1476
1494
}
1477
1495
1496
+ @ TypeAlias ("_" )
1497
+ static class Aliased {
1498
+ String name ;
1499
+ }
1500
+
1478
1501
private class LocalDateToDateConverter implements Converter <LocalDate , Date > {
1479
1502
1480
1503
public Date convert (LocalDate source ) {
You can’t perform that action at this time.
0 commit comments