public SourceRecordJson(@Nullable SourceRecord sourceRecord) {
    if (sourceRecord == null) {
      throw new IllegalArgumentException();
    }

    this.value = (Struct) sourceRecord.value();

    if (this.value == null) {
      this.event = new Event(null, null, null);
    } else {
      Event.Metadata metadata = this.loadMetadata();
      Event.Before before = this.loadBefore();
      Event.After after = this.loadAfter();

      this.event = new Event(metadata, before, after);
    }
  }
@Test
  public void testSourceRecordJson() {
    SourceRecord record = buildSourceRecord();
    SourceRecordJson json = new SourceRecordJson(record);

    String jsonString = json.toJson();

    String expectedJson =
        "{\"metadata\":"
            + "{\"connector\":\"test-connector\",\"version\":\"version-connector\","
            + "\"name\":\"test-connector-sql\","
            + "\"database\":\"test-db\",\"schema\":\"test-schema\",\"table\":\"test-table\"},"
            + "\"before\":{\"fields\":{\"country\":null,\"distance\":123.423,\"birthYear\":null,"
            + "\"name\":\"before-name\","
            + "\"temperature\":104.4,\"childrenAndAge\":null,\"age\":16}},"
            + "\"after\":{\"fields\":{\"country\":null,\"distance\":123.423,\"birthYear\":null,"
            + "\"name\":\"after-name\","
            + "\"temperature\":104.4,\"childrenAndAge\":null,\"age\":16}}}";

    assertEquals(expectedJson, jsonString);
  }