Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
thesamet committed Nov 23, 2023
1 parent b98221b commit 417570b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/scala/scalapb/json4s/AnyFormatSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ class AnyFormatSpec extends AnyFlatSpec with Matchers with JavaAssertions {
ScalaJsonPrinter.toJson(input) must be(optionalAnyJson)
}

"Any" should "serialize a timestamp value" in {
val optionalAnyJson = parse("""{
"optionalAny": {
"@type": "type.googleapis.com/google.protobuf.Timestamp",
"value": "1970-01-01T00:00:00Z"
}
}""")

val input = ScalaJsonParser.fromJson[AnyContainer](optionalAnyJson)

input.getOptionalAny.unpack[com.google.protobuf.Timestamp] must be(
com.google.protobuf.Timestamp()
)

ScalaJsonPrinter.toJson(input) must be(optionalAnyJson)
}

"Any" should "work when nested" in {
val nestedAny = parse("""{
| "optionalAny": {
Expand Down

0 comments on commit 417570b

Please sign in to comment.