@Override
  public void readFields(DataInput in) throws IOException {
    super.readFields(in);
    readFromInput(in);
  }
@Test
  public void testReadFields() throws IOException {
    // create a mock for DataOutput that will be used in the readFields method
    // this way we can capture and verify if correct arguments were passed
    DataInput in = mock(DataInput.class);

    // register the mock responses to be returned when particular method call happens
    // on the mocked object
    when(in.readByte()).thenReturn((byte) fileSplitName.length());
    // Answer implementation is used to guarantee the response in sequence of the mock method calls
    // since the same method is called many times, we need to return the responses in proper sequence
    when(in.readInt()).thenAnswer(new Answer<Integer>() {
      private int count = 0;
      private int[] answers = new int[]{basePath.length(), maxCommitTime.length(), deltaLogPaths.size(), deltaLogPaths.get(0).length()};

      @Override
      public Integer answer(InvocationOnMock invocationOnMock) throws Throwable {
        return answers[count++];
      }
    });
    Answer<Void> readFullyAnswer = new Answer<Void>() {
      private int count = 0;
      private byte[][] answers = new byte[][] {
          getUTF8Bytes(fileSplitName),
          getUTF8Bytes(basePath),
          getUTF8Bytes(maxCommitTime),
          getUTF8Bytes(deltaLogPaths.get(0)),
      };

      @Override
      public Void answer(InvocationOnMock invocation) throws Throwable {
        byte[] bytes = invocation.getArgument(0);
        byte[] answer = answers[count++];
        System.arraycopy(answer, 0, bytes, 0, answer.length);
        return null;
      }
    };
    doAnswer(readFullyAnswer).when(in).readFully(any());
    doAnswer(readFullyAnswer).when(in).readFully(any(), anyInt(), anyInt());

    // call readFields with mocked object
    HoodieRealtimeFileSplit read = new HoodieRealtimeFileSplit();
    read.readFields(in);

    // assert proper returns after reading from the mocked object
    assertEquals(basePath, read.getBasePath());
    assertEquals(maxCommitTime, read.getMaxCommitTime());
    assertEquals(deltaLogPaths, read.getDeltaLogPaths());
    assertEquals(split.toString(), read.toString());
  }