File tree 1 file changed +32
-0
lines changed
src/test/scala/com/fasterxml/jackson/module/scala/ser
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .module .scala .ser
2
+
3
+ import com .fasterxml .jackson .annotation .JsonPropertyOrder
4
+ import com .fasterxml .jackson .databind .MapperFeature
5
+ import com .fasterxml .jackson .module .scala .DefaultScalaModule
6
+ import org .junit .runner .RunWith
7
+ import org .scalatest .junit .JUnitRunner
8
+
9
+ object TransientFieldTest {
10
+ @ JsonPropertyOrder (Array (" x" ))
11
+ class ClassyTransient {
12
+ @ transient
13
+ val value = 3
14
+ def getValue = value
15
+ def getX = 42
16
+ }
17
+ }
18
+
19
+ @ RunWith (classOf [JUnitRunner ])
20
+ class TransientFieldTest extends SerializerTest {
21
+ import TransientFieldTest ._
22
+
23
+ val module = DefaultScalaModule
24
+
25
+ " DefaultScalaModule" should " normally ignore @transient annotations" in {
26
+ serialize(new ClassyTransient ) shouldBe """ {"x":42,"value":3}"""
27
+ }
28
+
29
+ it should " respect @transient annotation when feature enabled" in {
30
+ serialize(new ClassyTransient , newMapper.enable(MapperFeature .PROPAGATE_TRANSIENT_MARKER )) shouldBe """ {"x":42}"""
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments