@Test
public void testWithArgumentsAndMetadata() {

  LogData data =
      FakeLogData.withPrintfStyle("Foo='%s'", "bar")
          .setTimestampNanos(123456789000L)
          .addMetadata(COUNT_KEY, 23)
          .addMetadata(ID_KEY, "test ID");
  LogRecord record = SimpleLogRecord.create(data);
  assertThat(record.getLevel()).isEqualTo(Level.INFO);
  assertThat(record.getMessage()).isEqualTo("Foo='bar' [CONTEXT count=23 id=\"test ID\" ]");
  assertThat(record.getParameters()).isNull();
  // Just do this once for sanity checking - it's only for debugging.
  record.setMillis(123456789);
  assertThat(record.toString())
      .isEqualTo(
          "SimpleLogRecord {\n"
              + "  message: Foo='bar' [CONTEXT count=23 id=\"test ID\" ]\n"
              + "  arguments: <none>\n"
              + "  original message: Foo='%s'\n"
              + "  original arguments:\n"
              + "    bar\n"
              + "  metadata:\n"
              + "    count: 23\n"
              + "    id: test ID\n"
              + "  level: INFO\n"
              + "  timestamp (nanos): 123456789000\n"
              + "  class: com.google.FakeClass\n"
              + "  method: fakeMethod\n"
              + "  line number: 123\n"
              + "}");
}