File tree 1 file changed +15
-6
lines changed
spring-data-mongodb/src/test/kotlin/org/springframework/data/mongodb/core
1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package org.springframework.data.mongodb.core
17
17
18
- import com.mongodb.MongoClient
18
+ import com.mongodb.client.MongoClients
19
19
import org.junit.Test
20
+ import org.springframework.data.mongodb.core.mapping.Field
20
21
import org.springframework.data.mongodb.repository.MongoRepository
21
22
import org.springframework.data.mongodb.repository.support.MongoRepositoryFactory
22
23
import org.springframework.data.mongodb.test.util.Assertions.assertThat
23
24
24
- open class SuperType (open val field : Int )
25
+ open class SuperType (open var field : Int )
25
26
26
- class SubType (val id : String , override var field : Int = 1 ) : SuperType(field)
27
+ class SubType (val id : String , @Field(" foo" ) override var field : Int = 1 ) :
28
+ SuperType (field) {
29
+
30
+ fun setFields (v : Int ) {
31
+ field = v
32
+ super .field = v
33
+ }
34
+ }
27
35
28
36
interface MyRepository : MongoRepository <SubType , String >
29
37
30
38
class `KotlinOverridePropertyTests ` {
31
39
32
- val template = MongoTemplate (MongoClient (), " kotlin-tests" )
40
+ val template = MongoTemplate (MongoClients .create (), " kotlin-tests" )
33
41
34
42
@Test // DATAMONGO-2250
35
43
fun `Ambiguous field mapping for override val field` () {
36
44
37
- val repository = MongoRepositoryFactory (template).getRepository(MyRepository ::class .java)
45
+ val repository =
46
+ MongoRepositoryFactory (template).getRepository(MyRepository ::class .java)
38
47
39
48
var subType = SubType (" id-1" )
40
- subType.field = 3
49
+ subType.setFields( 3 )
41
50
42
51
repository.save(subType)
43
52
You can’t perform that action at this time.
0 commit comments