Class UnredactedDebugFormatForTest


  • public final class UnredactedDebugFormatForTest
    extends java.lang.Object
    These APIs are restricted to test-only targets, and are suitable for test purposes where it is impractical to compare protos directly via ProtoTruth (e.g. log output).
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String unredactedMultilineString​(MessageOrBuilder message)
      Like TextFormat.printer().printToString(message), but for test assertion purposes.
      static java.lang.String unredactedMultilineString​(UnknownFieldSet fields)
      Like TextFormat.printer().printToString(fields), but for test assertion purposes.
      static java.lang.String unredactedSingleLineString​(MessageOrBuilder message)
      Like TextFormat.printer().emittingSingleLine(true).printToString(message), but for test assertion purposes.
      static java.lang.String unredactedSingleLineString​(UnknownFieldSet fields)
      Like TextFormat.printer().emittingSingleLine(true).printToString(fields), but for test assertion purposes.
      static java.lang.String unredactedStringValueOf​(java.lang.Object object)
      Return String.valueOf() with the guarantee that any Protobuf Message.toString() invoked under this call always returns TextFormat (except for Message.toString() calls that are also under ProtobufToStringOutput.callWithDebugFormat).
      static java.lang.String unredactedToString​(java.lang.Object object)
      Return object.toString() with the guarantee that any Protobuf Message.toString() invoked under this call always returns TextFormat (except for Message.toString() calls that are also under ProtobufToStringOutput.callWithDebugFormat).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • unredactedMultilineString

        public static java.lang.String unredactedMultilineString​(MessageOrBuilder message)
        Like TextFormat.printer().printToString(message), but for test assertion purposes.
      • unredactedMultilineString

        public static java.lang.String unredactedMultilineString​(UnknownFieldSet fields)
        Like TextFormat.printer().printToString(fields), but for test assertion purposes.
      • unredactedSingleLineString

        public static java.lang.String unredactedSingleLineString​(MessageOrBuilder message)
        Like TextFormat.printer().emittingSingleLine(true).printToString(message), but for test assertion purposes.
      • unredactedSingleLineString

        public static java.lang.String unredactedSingleLineString​(UnknownFieldSet fields)
        Like TextFormat.printer().emittingSingleLine(true).printToString(fields), but for test assertion purposes.
      • unredactedToString

        public static java.lang.String unredactedToString​(java.lang.Object object)
        Return object.toString() with the guarantee that any Protobuf Message.toString() invoked under this call always returns TextFormat (except for Message.toString() calls that are also under ProtobufToStringOutput.callWithDebugFormat). This is particularly useful for toString calls on objects that contain Protobuf messages (e.g collections) and existing code expects toString() on these objects to contain Message.toString() outputs in TextFormat.
      • unredactedStringValueOf

        public static java.lang.String unredactedStringValueOf​(java.lang.Object object)
        Return String.valueOf() with the guarantee that any Protobuf Message.toString() invoked under this call always returns TextFormat (except for Message.toString() calls that are also under ProtobufToStringOutput.callWithDebugFormat). This is particularly useful for explicit and implicit String.valueOf() calls on objects that contain Protobuf messages (e.g collections) and may be null, and existing code expects toString() on these objects to contain Message.toString() outputs in TextFormat.