From 417570bdbe672133ef2ce9539c686caf64fa3ece Mon Sep 17 00:00:00 2001 From: Nadav Samet Date: Thu, 23 Nov 2023 08:23:28 -0800 Subject: [PATCH] wip --- .../scala/scalapb/json4s/AnyFormatSpec.scala | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/test/scala/scalapb/json4s/AnyFormatSpec.scala b/src/test/scala/scalapb/json4s/AnyFormatSpec.scala index fef25e4c..3069d22f 100644 --- a/src/test/scala/scalapb/json4s/AnyFormatSpec.scala +++ b/src/test/scala/scalapb/json4s/AnyFormatSpec.scala @@ -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": {