-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
PJ Fanning
committed
Jan 29, 2020
1 parent
552fc37
commit c77bf43
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/test/scala/com/fasterxml/jackson/module/scala/ser/OverrideValSerializerTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.fasterxml.jackson.module.scala.ser | ||
|
||
import java.util.UUID | ||
|
||
import com.fasterxml.jackson.module.scala.DefaultScalaModule | ||
import org.junit.runner.RunWith | ||
import org.scalatestplus.junit.JUnitRunner | ||
|
||
@RunWith(classOf[JUnitRunner]) | ||
class OverrideValSerializerTest extends SerializerTest { | ||
lazy val module = DefaultScalaModule | ||
|
||
trait MyTrait { | ||
val id: UUID | ||
val `type`: String | ||
} | ||
|
||
class Base(val id: UUID) extends MyTrait { | ||
override val `type`: String = "baseclass" | ||
} | ||
|
||
case class Sub(override val id: UUID, something: String) extends Base(id) | ||
|
||
"DefaultScalaModule" should "handle overrides in vals" in { | ||
val id = UUID.randomUUID() | ||
//TODO https://github.com/FasterXML/jackson-module-scala/issues/218 | ||
//the json should also include "id":"<idAsString>" | ||
serialize(Sub(id, "something")) shouldBe """{"type":"baseclass","something":"something"}""" | ||
} | ||
} |