File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
src/test/scala/tools/jackson/module/scala/ser Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ package tools .jackson .module .scala .ser
2
+
3
+ import com .fasterxml .jackson .annotation .JsonFormat
4
+ import tools .jackson .databind .cfg .MutableConfigOverride
5
+ import tools .jackson .module .scala .{DefaultScalaModule , JacksonModule }
6
+
7
+ class NumberSerializerTest extends SerializerTest {
8
+
9
+ val module : JacksonModule = DefaultScalaModule
10
+
11
+ " NumberSerializer" should " serialize BigDecimal as a number" in {
12
+ serialize(BigDecimal (" 123.456" )) shouldBe " 123.456"
13
+ }
14
+
15
+ it should " serialize BigDecimal as a number (JsonFormat.Shape.STRING)" in {
16
+ val builder = newBuilder
17
+ .withConfigOverride(classOf [BigDecimal ],
18
+ (c : MutableConfigOverride ) => c.setFormat(JsonFormat .Value .forShape(JsonFormat .Shape .STRING )))
19
+ serialize(BigDecimal (" 123.456" ), builder.build()) shouldBe """ "123.456""""
20
+ }
21
+
22
+ it should " serialize BigInt as a number" in {
23
+ serialize(BigInt (" 12345678901234567890" )) shouldBe " 12345678901234567890"
24
+ }
25
+
26
+ it should " serialize Int as a number" in {
27
+ serialize(42 ) shouldBe " 42"
28
+ }
29
+
30
+ it should " serialize Long as a number" in {
31
+ serialize(12345678901234L ) shouldBe " 12345678901234"
32
+ }
33
+
34
+ }
You can’t perform that action at this time.
0 commit comments