Skip to content

add test that shows an issue when scala 2.13 or scala 3 used #597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.fasterxml.jackson.module.scala.ser

import com.fasterxml.jackson.annotation.{JsonAutoDetect, PropertyAccessor}
import com.fasterxml.jackson.module.scala.DefaultScalaModule

case object CaseObjectExample {
Expand All @@ -9,12 +10,35 @@ case object CaseObjectExample {

class CaseObjectSerializerTest extends SerializerTest {

case object Foo {
val field: String = "bar"
}

def module = DefaultScalaModule

"An ObjectMapper with the DefaultScalaModule" should "serialize a case object as a bean" in {
serialize(CaseObjectExample) should (
equal ("""{"field1":"test","field2":42}""") or
equal ("""{"field2":42,"field1":"test"}""")
equal ("""{"field2":42,"field1":"test"}""")
)
}

it should "serialize a case object when visibility settings set" ignore {
val mapper = newBuilder
.visibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
.visibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE)
.build()
mapper.writeValueAsString(CaseObjectExample) should (
equal("""{"field1":"test","field2":42}""") or
equal("""{"field2":42,"field1":"test"}""")
)
}

it should "serialize an inner case object when visibility settings set" in {
val mapper = newBuilder
.visibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
.visibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE)
.build()
mapper.writeValueAsString(Foo) shouldEqual """{"field":"bar"}"""
}
}