File tree Expand file tree Collapse file tree 6 files changed +16
-20
lines changed
src/test/scala/tools/jackson/module/scala Expand file tree Collapse file tree 6 files changed +16
-20
lines changed Original file line number Diff line number Diff line change 11package tools .jackson .module .scala
22
3- import tools .jackson .databind .{ MapperFeature , ObjectMapper }
3+ import tools .jackson .databind .ObjectMapper
44import tools .jackson .databind .json .JsonMapper
55import org .scalatest .Outcome
66import org .scalatest .flatspec .FixtureAnyFlatSpec
@@ -11,9 +11,7 @@ class BaseFixture extends FixtureAnyFlatSpec with Matchers {
1111 type FixtureParam = ObjectMapper
1212
1313 def withFixture (test : OneArgTest ): Outcome = {
14- val builder = JsonMapper .builder()
15- .disable(MapperFeature .SORT_PROPERTIES_ALPHABETICALLY )
16- .addModule(DefaultScalaModule )
14+ val builder = JsonMapper .builder().addModule(DefaultScalaModule )
1715 val mapper = builder.build()
1816 test(mapper)
1917 }
Original file line number Diff line number Diff line change @@ -136,7 +136,8 @@ class ClassTagExtensionsTest extends JacksonTest {
136136 val result = mapper.writerWithView[PublicView ].writeValueAsString(instance)
137137 result should equal(""" {"foo":"foo"}""" )
138138 val resultInView = mapper.writerWithView[PrivateView ].writeValueAsString(instance)
139- resultInView should equal(""" {"foo":"foo","bar":42}""" )
139+ // JSON order for non-constructor params changed in Jackson 3 due to https://github.com/FasterXML/jackson-databind/pull/4572
140+ resultInView should equal(""" {"bar":42,"foo":"foo"}""" )
140141 }
141142
142143 it should " produce writer with type" in {
Original file line number Diff line number Diff line change 11package tools .jackson .module .scala
22
33import tools .jackson .databind .json .JsonMapper
4- import tools .jackson .databind .{MapperFeature , JacksonModule => DatabindModule }
4+ import tools .jackson .databind .{JacksonModule => DatabindModule }
55
66abstract class JacksonTest extends BaseSpec {
77 def module : DatabindModule
88
9- def newBuilder : JsonMapper .Builder = {
10- JsonMapper .builder()
11- .addModule(module)
12- .disable(MapperFeature .SORT_PROPERTIES_ALPHABETICALLY )
13- }
9+ def newBuilder : JsonMapper .Builder = JsonMapper .builder().addModule(module)
1410
1511 def newMapper : JsonMapper = newBuilder.build()
1612}
Original file line number Diff line number Diff line change @@ -244,8 +244,5 @@ class CreatorTest extends DeserializationFixture {
244244 f.convertValue(node, new TypeReference [PositiveLong ] {}).value shouldEqual node.asLong()
245245 }
246246
247- private def initBuilder (): JsonMapper .Builder = {
248- JsonMapper .builder()
249- .disable(MapperFeature .SORT_PROPERTIES_ALPHABETICALLY )
250- }
247+ private def initBuilder (): JsonMapper .Builder = JsonMapper .builder()
251248}
Original file line number Diff line number Diff line change @@ -160,7 +160,8 @@ class CaseClassSerializerTest extends SerializerTest {
160160 val bean = new NonCaseWithBeanProperty
161161 bean.id = 1
162162 bean.bar = " foo"
163- serialize(bean) should equal( """ {"id":1,"bar":"foo"}""" )
163+ // JSON order for non-constructor params changed in Jackson 3 due to https://github.com/FasterXML/jackson-databind/pull/4572
164+ serialize(bean) should equal( """ {"bar":"foo","id":1}""" )
164165 }
165166
166167 it should " serialize a nested case class" in {
@@ -185,7 +186,8 @@ class CaseClassSerializerTest extends SerializerTest {
185186 def isBoolean = boolean
186187 }
187188 val foo = new Foo (" str" , false )
188- serialize(foo) should equal (""" {"string":"str","boolean":false}""" )
189+ // JSON order for non-constructor params changed in Jackson 3 due to https://github.com/FasterXML/jackson-databind/pull/4572
190+ serialize(foo) should equal (""" {"boolean":false,"string":"str"}""" )
189191 }
190192
191193 it should " serialize java getters returning java collections" in {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ package tools.jackson.module.scala.ser
22
33import com .fasterxml .jackson .annotation ._
44import tools .jackson .databind .jsontype .DefaultBaseTypeLimitingValidator
5- import tools .jackson .databind .{JsonNode , ObjectMapper }
5+ import tools .jackson .databind .{JsonNode , MapperFeature , ObjectMapper }
66import tools .jackson .module .scala .{DefaultScalaModule , JacksonModule }
77
88import java .util
@@ -130,11 +130,13 @@ class OptionSerializerTest extends SerializerTest {
130130
131131 it should " support default typing" in {
132132 case class User (name : String , email : Option [String ] = None )
133- val mapper = newMapper
133+ val mapper = newBuilder.disable( MapperFeature . SORT_PROPERTIES_ALPHABETICALLY ).build()
134134 val user = User (" John Smith" , Some (" john.smith@unit.uk" ))
135135 val expected = """ {"name":"John Smith","email":"john.smith@unit.uk"}"""
136136 mapper.writeValueAsString(user) shouldEqual expected
137- val mapper2 = newBuilder.activateDefaultTyping(new DefaultBaseTypeLimitingValidator ).build()
137+ val mapper2 = newBuilder.disable(MapperFeature .SORT_PROPERTIES_ALPHABETICALLY )
138+ .activateDefaultTyping(new DefaultBaseTypeLimitingValidator )
139+ .build()
138140 mapper2.writeValueAsString(user) shouldEqual expected
139141 }
140142
You can’t perform that action at this time.
0 commit comments