File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
src/test/scala/com/fasterxml/jackson/module/scala/deser Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 1
1
package com .fasterxml .jackson .module .scala .deser
2
2
3
3
import com .fasterxml .jackson .annotation .JsonCreator
4
- import com .fasterxml .jackson .databind .ObjectMapper
4
+ import com .fasterxml .jackson .core .`type` .TypeReference
5
+ import com .fasterxml .jackson .databind .{JsonNode , ObjectMapper }
6
+ import com .fasterxml .jackson .databind .node .IntNode
7
+
8
+ class PositiveLong private (val value : Long ) {
9
+ override def toString () = s " PositiveLong( $value) "
10
+ }
11
+ object PositiveLong {
12
+ @ JsonCreator
13
+ def apply (long : Long ): PositiveLong = new PositiveLong (long)
14
+ @ JsonCreator
15
+ def apply (str : String ): PositiveLong = new PositiveLong (str.toLong)
16
+ }
5
17
6
18
object CreatorTest
7
19
{
@@ -50,7 +62,6 @@ object CreatorTest
50
62
case class ConstructorWithOptionStruct (s : Option [Struct1 ] = None )
51
63
}
52
64
53
-
54
65
class CreatorTest extends DeserializationFixture {
55
66
import CreatorTest ._
56
67
@@ -147,4 +158,9 @@ class CreatorTest extends DeserializationFixture {
147
158
deser2.s shouldEqual Some (Struct1 (" name" ))
148
159
f.writeValueAsString(ConstructorWithOptionStruct ()) shouldEqual """ {"s":null}"""
149
160
}
161
+
162
+ it should " support multiple creator annotations" in { f =>
163
+ val node : JsonNode = f.valueToTree[IntNode ](10 )
164
+ f.convertValue(node, new TypeReference [PositiveLong ] {}).value shouldEqual node.asLong()
165
+ }
150
166
}
You can’t perform that action at this time.
0 commit comments