1
+ /*
2
+ * Copyright (C) 2017/2019 Litote
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org.litote.kmongo.issues
18
+
19
+ import com.fasterxml.jackson.annotation.JsonIdentityInfo
20
+ import com.fasterxml.jackson.annotation.JsonIdentityReference
21
+ import com.fasterxml.jackson.annotation.ObjectIdGenerators
22
+ import org.junit.Test
23
+ import org.litote.kmongo.AllCategoriesKMongoBaseTest
24
+ import org.litote.kmongo.findOne
25
+ import org.litote.kmongo.issues.Issue135JsonIdentityInfo.Entry
26
+ import org.litote.kmongo.save
27
+ import java.util.Collections
28
+ import kotlin.test.assertEquals
29
+
30
+ /* *
31
+ *
32
+ */
33
+ class Issue135JsonIdentityInfo : AllCategoriesKMongoBaseTest <Entry >() {
34
+
35
+ @JsonIdentityInfo(generator = ObjectIdGenerators .PropertyGenerator ::class , property = " uri" )
36
+ class Entry () {
37
+
38
+ constructor (uri: String ) : this () {
39
+ this .uri = uri
40
+ }
41
+
42
+ lateinit var uri: String
43
+
44
+ @JsonIdentityReference(alwaysAsId = true )
45
+ var contains: MutableSet <Entry > = Collections .synchronizedSet(HashSet ())
46
+
47
+ }
48
+
49
+ @JsonIdentityInfo(generator = ObjectIdGenerators .PropertyGenerator ::class , property = " uri" )
50
+ class OriginalEntry (val uri : String ) {
51
+ @JsonIdentityReference(alwaysAsId = true )
52
+ var contains: MutableSet <OriginalEntry > = Collections .synchronizedSet(HashSet ())
53
+ }
54
+
55
+ @Test
56
+ fun saveDoesNotFail () {
57
+ val entry = Entry (" http://litote.org/kmongo" )
58
+ col.save(entry)
59
+ assertEquals(entry.uri, col.findOne()?.uri)
60
+ }
61
+
62
+ }
0 commit comments