15
15
*/
16
16
package org .springframework .data .mongodb .repository .support ;
17
17
18
+ import static org .hamcrest .CoreMatchers .*;
18
19
import static org .junit .Assert .*;
19
20
import static org .mockito .Mockito .*;
20
21
29
30
import org .springframework .data .mongodb .core .MongoTemplate ;
30
31
import org .springframework .data .mongodb .core .convert .MongoConverter ;
31
32
import org .springframework .data .mongodb .core .mapping .MongoPersistentEntity ;
32
- import org .springframework .data .mongodb .core .mapping .MongoPersistentProperty ;
33
33
import org .springframework .data .mongodb .repository .Person ;
34
34
import org .springframework .data .mongodb .repository .query .MongoEntityInformation ;
35
+ import org .springframework .data .repository .Repository ;
35
36
36
37
/**
37
38
* Unit test for {@link MongoRepositoryFactory}.
@@ -48,17 +49,18 @@ public class MongoRepositoryFactoryUnitTests {
48
49
MongoConverter converter ;
49
50
50
51
@ Mock
51
- MappingContext <MongoPersistentEntity <?>, MongoPersistentProperty > mappingContext ;
52
+ @ SuppressWarnings ("rawtypes" )
53
+ MappingContext mappingContext ;
52
54
53
55
@ Mock
54
56
@ SuppressWarnings ("rawtypes" )
55
57
MongoPersistentEntity entity ;
56
58
57
59
@ Before
58
- @ SuppressWarnings ({ "rawtypes" , " unchecked" } )
60
+ @ SuppressWarnings (" unchecked" )
59
61
public void setUp () {
60
62
when (template .getConverter ()).thenReturn (converter );
61
- when (converter .getMappingContext ()).thenReturn (( MappingContext ) mappingContext );
63
+ when (converter .getMappingContext ()).thenReturn (mappingContext );
62
64
}
63
65
64
66
@ Test
@@ -72,4 +74,23 @@ public void usesMappingMongoEntityInformationIfMappingContextSet() {
72
74
MongoEntityInformation <Person , Serializable > entityInformation = factory .getEntityInformation (Person .class );
73
75
assertTrue (entityInformation instanceof MappingMongoEntityInformation );
74
76
}
77
+
78
+ /**
79
+ * @see DATAMONGO-385
80
+ */
81
+ @ Test
82
+ @ SuppressWarnings ("unchecked" )
83
+ public void createsRepositoryWithIdTypeLong () {
84
+
85
+ when (mappingContext .getPersistentEntity (Person .class )).thenReturn (entity );
86
+ when (entity .getType ()).thenReturn (Person .class );
87
+
88
+ MongoRepositoryFactory factory = new MongoRepositoryFactory (template );
89
+ MyPersonRepository repository = factory .getRepository (MyPersonRepository .class );
90
+ assertThat (repository , is (notNullValue ()));
91
+ }
92
+
93
+ interface MyPersonRepository extends Repository <Person , Long > {
94
+
95
+ }
75
96
}
0 commit comments